Hi,
I hope this post will help someone to avoid problems I had - and I hope that TI will resolve the issues in the future releases of HALCoGen.
The problems I had are related to using FreeRTOS on TMS570. I used HALCoGen to generate code. First of all I want to say that it is a great idea to include FreeRTOS in HALCoGen and it really (generally) works fine. However, there are three issues that took me two days to resolve:
1. File os_port.c in line 36 defines portINITIAL_SPSR as 0x1F. This is wrong, the value has to be 0x31F. The problem is that in Cortex R4 core bit 9 of CPSR defines endianness. This bit has to be set to 1, otherwise endianness is wrong. The effect of the wrong constant was that after the first context switch the endianness was wrong, address of a RAM variable was loaded with reversed bytes and CPU landed in memory access trap. I also set bit 8 to 1 - this is not related to the problem I had, but the bit was set by default after reset, so I set it in the constant as well.
2. Related to previous problem: File os_portasm.inc in line 60 has msr spsr_cf, r0. The extension "_cf" means that only bits 31 to 24 and 7 to 0 are copied. This leaves previously mentioned bit 9 out, which is wrong. I changed the line to msr spsr_cxf, r0 - the "x" I added in the extension means that also bits 15 to 8 are copied. Effects of this issue were very problematic because the state of the bit 9 was depending on (random!) previous state of the bit, so that the code sometimes worked and sometimes not.
3. File os_portasm.asm has in lines 45 and 59 .if 1, which causes wrong part of the code to be included. The function vPortPreemptiveTick does not save and restore context because of this - and result is that effectively the preemptive task switch does not work. I changed both lines to .if 0 and after that the FreeRTOS was working as expected.
I would appreciate comments to the above described issues, specially from someone responsible for HALCoGen (which is btw very good tool ;) ).
BR