FreeRTOS and PIC32 need PBCLK to be 12mhz.

roujesky wrote on Monday, April 04, 2011:

Using FreeRTOS on a custom PIC32 based board.   Literally, just been running for a day! :)   I am a newb to both PIC32 and FreeRTOS, so please be gentle.   I need the UART to communicate with a device that is running a baud rate of 58,252.   Yes, weird!   Anyway, to get this baud rate, I need a PBCLK of 12mhz.   I cannot seem to find where in FreeRTOS it sets PBCLK.   Probably me :(    Anyway, I set configPERIPHERAL_CLOCK_HZ to 12000000UL thinking this would do it.  I dont think it is right, because I have a LED flashing task which flashes the led every second.   when I change configPERIPHERAL_CLOCK_HZ from 40mhz to 12mhz, my led blinks a lot faster (too fast).   I am not sure where to look for the correct way to do this.   I bought the ebook “Using the FreeRTOS Real Time Kernel - A Practical Guide”, but it does not address this at all.


rtel wrote on Tuesday, April 05, 2011:

You need to look at the C32 libraries (that come with the compiler, not with FreeRTOS. 

In main.c you will see a function called prvSetupHardware() that makes a call to the (Microchip) library functions     SYSTEMConfigPerformance( configCPU_CLOCK_HZ - 1 ) and mOSCSetPBDIV( OSC_PB_DIV_2 );  You then need to set the configPERIPHERAL_CLOCK_HZ setting in FreeRTOSConfig.h to match whatever you set the clock to using these library functions.


roujesky wrote on Wednesday, April 06, 2011:

Thanks!   That helped a lot.   Continuing on! :slight_smile: