New Bie on MPC5510 ISR Implementation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

New Bie on MPC5510 ISR Implementation

1,625 Views
nandu
Contributor III

Hello every one

 

I'm very new 32-bit MCU and now I am doing a project on MPC551x MCU. I badly need you all guys help.

 

1. I have the MPC5510 EVB with me.

 

2. I created a new project using the "MPC55xx New Project Wizard" in Codewarrior of version 5.9.0

 

3. I selected the Target for my project as "internal_FLASH"

 

4. Now, I want to understand how to implement a basic Interrupt Service Routine for any interrupt source. I choose to implement a Periodic Interrupt Timer T1 for every 10ms. So, I initialize the Periodic Interrupt Timer module registers as follows.

----------------------------------------------------------------------------------------------- 

PIT.CTRL.B.MDIS    = 0;                /* enable the clocks for PIT timer1 to timer 8 */

PIT.TLVAL1.B.TSV  = 0x00003E7F;  /* load this value to generate 10ms with default 16Mhz IRC */

PIT.INTEN.B.TIE1    = 1;               /* enable the PIT Timer 1 interrupt*/

PIT.INTSEL.B.ISEL1 = 1;               /* PIT timer 1 generates interrupt if enabled */

PIT.EN.B.PEN1        = 1;               /* enable the PIT Timer 1 timer */ 

----------------------------------------------------------------------------------------------- 

 

5. And now, I wrote a simple ISR for the Timer 1 interrupt where i am just clearing the corresponding timer interrupt flag (TIF1) and incrementing a test variable.

 

6. Every thing is fine, but I could not able to figure out how to link this ISR to the default vector table or I couldnt make this ISR to execute when the interrupt occurs.

 

FYI, I have already worked with the HCS & HCS(X) mcu's before where we can link the ISR to the internal process by adding the "ISR name and vector number" to the .prm file and using modifier "interrupt" and "#pragma CODE_SEG  NON_BANKED" statements at the location of Interrupt service routine definition.

 

But, what is the procedure in this MPC551x MCU environment ? I know the INTC module has two modes. One is Software vector mode and the other is Hardware vector mode and the default mode will be software vector mode and the correspoding ivor registers is IOVR #4.

 

*** I tried reading all the default files in the project, but still could not make this happen. I hope your ideas will be greatly helpful to me. I have also tried analyzing and understand this process using the example projects installed in Freescale folder. i.e. 551x_Cookbook project examples which is again difficult for me as almost all the projects are in assembly code but not in C code. Because I'm not familiar with the assembly code.

 

*** I have attached this simple project file with this post, please have a look at it.. and I would like to request you to please make the necessary modifications to .lcf files or some other startup files or anything that is required to my project file. So, that I can download and debug and check to compare and analyze how to implement the ISR. By the way, my debugger is the default Nexus Debugger with USB Power PC NEXUS Multilink.

Message Edited by nandu on 2009-04-30 03:38 PM
Message Edited by t.dowe on 2009-08-28 03:35 PM
0 Kudos
1 Reply

409 Views
ndk
Contributor III

Hi, 

 

In order to write and ISR in 'C' language in a default project created for MPC551x family, we just need to add the below line 

in the initialization phase of the project i.e. before the infinite loop of the main() function.

 

INTC_InstallINTCInterruptHandler(PIT_ISR, 149, 1);     

 

where PIT_ISR here is the isr name, 149 is the vector number and '1' is the priority level.

 

for example....

 

/**************************************************************/

/* start of file (main.c)        */

/**************************************************************/

 

#include "MPC551x.h"

#include "IntcInterrupts.h"

void PIT_ISR(void)
{
}
vodi init_PIT(void)
{
}
void main(void)
{
init_PIT();
INTC_InstallINTCInterruptHandler(PIT_ISR, 149, 1);   
for(;:smileywink:
{
}
}

/**************************************************************/

/* end of file        */

/**************************************************************/

 

0 Kudos