On the dsPIC demo, what files can I remove? I want to replace the demo files with my own files but can’t figure out which ones can be removed. The manual says to “strip out the source files that define the demo tasks” but I don’t know which ones I can remove. I started removing files and then got into a mess with lots of errors that some functions couldn’t be found. Is there a list of the files that are required?
Grumble grumble. It looks like I can safely remove blocktim, crflash, lcd, ParTest, serial and timertest but when I add one (1) of my C files and a header, I start getting errors: …\…\compile_rules.o: Link Error: Could not allocate section .nbss, size = 2194 bytes, attributes = bss near
Link Error: Could not allocate data memory
So this doesn’t look promising. Is there any way to fix this up? Thanks for any help!
See http://www.freertos.org/a00017.html - anything that is in the FreeRTOS/Source directory is part of FreeRTOS and required - anything that is in the FreeRTOS/Demo directory is part of the demo app and is not required.
A quick and simple way is to remove anything that is in the FreeRTOS/Demo directory other than main(), then delete the whole of main() other than vTaskStartScheduler(), finally create your own tasks before vTaskStartScheduler() is called.
If you run out of RAM then reduce configTOTAL_HEAP_SIZE in FreeRTOSConfig.h. I think this is an FAQ.
Thanks Richard. Unfortunately, when I remove blocktim, crflash, lcd, ParTest, serial and timertest and add one (1) of my C files and a header, I start getting the Link errors: “…\…\compile_rules.o: Link Error: Could not allocate section .nbss, size = 2194 bytes, attributes = bss near Link Error: Could not allocate data memory.” I haven’t removed any header files and still have croutine.c and .h, heap_1.c, list.c, main.c, port.c, portasm_dsPIC.s, queue.c and .h, tasks.c, FreeRTOSConfig.h, semphr.h and task.h in addition to my .c and .h files. Is that correct?
No, I missed that about the configTOTAL_HEAP_SIZE. I didn’t see that in the FAQ. I have made a guess at decreasing it and now have another error for my function that I call only one time on start up and right now, it’s the only function that I’ve included in the project:
c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe Error: A heap is required, but has not been specified.
It looks like I’ve gotten in over my head on this as I have no idea what to do. I see chapter 5 in the eBook and I see heap_1.c. Is the kernel expecting to find and call pvPortMalloc to do the memory allocation or do I have to call it from my function?
The linker will require a heap if functions you have added use calls to malloc(). FreeRTOS does not call malloc but instead calls pvPortMalloc(). This allows the malloc implementation to be replaced and this is what heap_1, heap_2 and heap_3 do. Does your code call malloc()? If so try replacing it with pvPortMalloc() instead.