MPLAB PIC18F Quick Start question

davidhaile wrote on Wednesday, February 11, 2009:

I’m browsing around today between projects and thought I’d give FreeRTOS a try.  I’ve ported the demos to a Microchip PIC18F4680 demo board - it was easy and the code is basically running.  I have a couple of questions about FreeRTOS’ treatment of Microchip’s infamous configuration bits.

1.) How do I tell FreeRTOS how the CPU clock rate?  I like to use a 32MHz internal oscillator.

2.) Did FreeRTOS anticipate Microchip’s configuration bits?  Where did it set them up?  I scanned the source and didn’t find any instances of “#pragma config” but maybe they did it some other way.  Where is this documented?

I’m assuming that I have to add #pragma’s to get it to run on the internal oscillator.

I’ll eventually figure this out but this forum may give me the answer quicker.

David Haile
Fort Collins, CO

felis_co wrote on Wednesday, February 11, 2009:

1) #define configCPU_CLOCK_HZ in FreeRTOSConfig.h
2) No.

picmeup wrote on Wednesday, February 11, 2009:

2) again. The PIC32 port sets up bits in main.c with #pragma. The PIC24 port uses the MPLAB IDE settings so no pragmas in source. Cant remember which method pic18 port use.

davidhaile wrote on Wednesday, February 11, 2009:

Thanks a ton.  I’ll also checkout the PIC32 port and see what was done with pragma’s.  That’s my preferred method.

davidhaile wrote on Wednesday, February 11, 2009:

What a pain in the buttocks!  I’m just trying to get any of the three standard demonstrations to work on a different processor than how the demo was written - PIC18F4680.  I’ve figured out the linker script file differences, it compiles and runs, but vTaskStartScheduler() always returns - it never starts the tasks.  I’ve gone through the “how to port to your hardware” and have put in a lot of debug code but haven’t found the problem.  I’ve increased the stack size to 256 and the heap size to 2048.  Those are double the size as distributed.

I’m still working on it but would appreciate if someone would throw some hints up here.  I’ll give back to this community once I get the code working and become an “expert”!

felis_co wrote on Wednesday, February 11, 2009:

vTaskStartScheduler() returns when there is not enough memory to start an idle task. Memory for idle task is defined in #define configMINIMAL_STACK_SIZE in FreeRTOSConfig.h. You may also want to take a
look at this: