I created a "bare board" project in CW 10.2 for MPC5606S.
After I had a lot of problems with triggering interrupt I decided to try also with PIT peripheral to keep it simpler (and some sample code for this is already available under examples).
The program contains:
- sources from CW bare board project (automaticaly generated)
- simple code to initialize and start the timer
- I initialize the interrupt vector --> INTC_InstallINTCInterruptHandler(Pit1ISR, 60, 1);
- I enable all interrupt priorities --> INTC.CPR.B.PRI = 0;
After that when the interrupt occurs the CPU crashes. I also managed to debug the interrupt handler function (INTC_INTCInterruptHandler) but I am not sure if this is good since it is not recommended to read INTC.IACKR multiple times - I got a function pointer value of 0x00000000, but the register value points directly to the correct function pointer address of the PIT IRQ.
Could someone help me solve this problem?
Solved! Go to Solution.
So I got an answer from Freescale support:
The issue is the “ivor_branch_table_p1”, defined in ivor_branch_table.c is not linked properly. Thus when exception (IVOR4) happens, the INTC_INTCInterruptHandler is not called. So please try to comment following line within the ivor_branch_table.c file …/* Set interrupt handlers *///asm void ivor_branch_table_p1(void); comment this line#pragma section code_type ".ivor_branch_table" ….Also if the RAM target is used the #define CALL_USR_INIT 1 should be added to the INT_RAM_VLE.prefix file, thus interrupt initialization is called also for a RAM target.Hope it helps.
If you want to avoid the compiler warning you can instead move the commented out function declaration between the pragmas and function definition.
I am still waitng for answer regarding a more "permanent" solution to the problem...
So after I lost about 1 day of dancing around this problem I found the cause of this problem.
The problem is in CodeWarrior v10.2, since it apparently doesn't correctly create the startup/initialization files. When I created a project with CodeWarrior for 55xx/56xx v2.8 the same code didn't crash when interrupts occured. Then I was also able to import the CW v2.8 to CW v10.2 and the project was still working.
Now I will try to find out exactly what causes this problem and I will probably also send a bug report to Freescale.
So I got an answer from Freescale support:
The issue is the “ivor_branch_table_p1”, defined in ivor_branch_table.c is not linked properly. Thus when exception (IVOR4) happens, the INTC_INTCInterruptHandler is not called. So please try to comment following line within the ivor_branch_table.c file …/* Set interrupt handlers *///asm void ivor_branch_table_p1(void); comment this line#pragma section code_type ".ivor_branch_table" ….Also if the RAM target is used the #define CALL_USR_INIT 1 should be added to the INT_RAM_VLE.prefix file, thus interrupt initialization is called also for a RAM target.Hope it helps.
If you want to avoid the compiler warning you can instead move the commented out function declaration between the pragmas and function definition.
I am still waitng for answer regarding a more "permanent" solution to the problem...