rtel wrote on Friday, June 12, 2015:
[moved to the support forum from a private email]
I am using:
MPLAB X V3.00
MPLAB ICD 3
Compiler = XC16 (V1.24)
CPU = Microchip p24EP256GU810
The original project was designed for the PIC24F. To get it to compile on the PIC24EP, I did the following:
- Loaded the original project into MPLAB X
- Changed the device from the PIC24F to the p24EP256GU810 in MPLAB X IDE project.
- There was an issue with the size of ucHeap[ configTOTAL_HEAP_SIZE ] in heap_1.c. The compiler comlained about it being too large for “near” space. So I added the attribute to put it into far space and that seemed to fix that.
static unsigned char attribute((far)) ucHeap[ configTOTAL_HEAP_SIZE ];
- Included the device specific p24EP256GU810.h file in FreeRTOSConfig.h
- Removed the hardware configuration from main and replaced it with an oscillator configuration file.
- Commented out everything in main, and added an LED blink loop to see if everything was setup correctly without the FreeRTOS.
- Once that worked, removed the LED loop and uncommented the scheduler.
I have several routines enabled looking for traps. I receive misaligned read or write attempts (address errors) shortly after running the application. I believe the address that it was trying to access was in the prvCheckDelayedList function. I tried messing with the heap and stack sizes, and various settings in the FreeRTOSConfig.h file, but always got the same result.
At this point I went online and started reading the FreeRTOS forum to try to get some clues. I found the FreeRTOS Interactive link that points to Contributed Vs Official Code. I went to the separate forum that had Microchip information. Here is where I found “FreeRTOS V8.2.0 port for ALL 16 bit PICs with hardware stack checking (SPLIM)”.
The link was fairly recent, so I thought I would give it a shot. Mike has written port.c and portmap.h files and said these would just drop in am make things work. So I gave it a shot, and it seems to work for several minutes at least.
Is the difference due to the different architectures between the PIC24F and the PIC24ep?
I have since moved on and am adding a C1 interrupt for a CAN interface and some new vTasks. After adding this, I am having issues with address errors again. It happens routinely ~50 seconds after I start. The CAN interface is perfectly happy sending and receiving CAN messages, then the 50 second mark happens and I get an address error trap. (incidentally, I believe it is in the uxListRemove function when the address error occurs). So I probably don’t have my ISR working well with FreeRTOS.
I have read the documentation and the forums. The documentation says to do an assembly language wrapper that stores the context, runs the ISR, then restores the context. The example is done using the C30 compiler, but I haven’t found a way to implement a wrapper using the XC16 compiler. The closest thing that I have found is using a preprologue directive that will basically run an assembly language program before the ISR. But there is no postprologue, so I haven’t figured out how to restore the context after the ISR. On the forum, there is an example for the PIC24ep in which a person used a Yield in the ISR. Everything that I read says don’t do that. So can you help out with the correct way to write an ISR function for interfacing to FreeRTOS using the XC16 compiler?