Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

P-star don't run cod with ADC or UART enabled



I have a P-Star with Pic18F25K50 module.
I make a simple con in order read an ADC input from an accelerometer but, after I upload the cone in p-star, the module remain in bootloader mode.
I try after that to make a simple code, blinking a LED and it works well after upload.
After that, I modify the first code to add the blink LED routine. The problem is: if ADC=enabled (or UART, or both), the p-star remain in bootloader mode; if ADC=desabled, the code works and p-star pass the bootloader mode to normal mode.
The code is written in MikroeC for PIC.
Cod.rar (28.5 KB)

Do you have encountered this type of behavior?

Thank you, Mihai


Hello, Mihai.

I took a look at your HEX file, and it looks like the function for initializing the ADC was placed at address 0x1C, which is in the area reserved for the P-Star’s bootloader (0 to 0x1FFF). When your code tries to call that function, it will end up starting the bootloader instead.

Instead of just putting “org 0x2000” on your main function, you will need to find a way to move all functions, data, and entry vectors be at 0x2000 or above.

I recommend checking the documentation of mikroC PRO for PIC, and in particular the linker, to see if it has some kind of option to specify what range of flash memory to use. Please let us know what you find out.