How to light a LED through INTC module in MPC5604P

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to light a LED through INTC module in MPC5604P

1,050 次查看
zhoutianyuan
Contributor I

Hi,friends!

   I've watched the  example code ,and the main function as follows:

void main (void)

{

    vuint32_t i = 0;    /* Dummy idle counter */

 

 

  initModesAndClock();  /* MPC56xxP/B/S: Initialize mode entries, set sysclk = 64 MHz*/

  disableWatchdog();    /* Disable watchdog */

  initIrqVectors();/* Initialize exceptions: only need to load IVPR */
  initINTC();/* Initialize INTC for software vector mode */
  initPIT();  /* Initialize PIT1 for 1KHz IRQ, priority 2 */
  initSwIrq4();/* Initialize software interrupt 4 */
  enableIrq();  /* Ensure INTC current prority=0 & enable IRQ */

 

  while (1)

  {

i++;
  }

}

void Pit1ISR(void) {

  Pit1Ctr++;                  /* Increment interrupt counter */

  if ((Pit1Ctr & 1)==0) {     /* If PIT1Ctr is even*/

    INTC.SSCIR[4].R = 2;      /*  then nvoke software interrupt 4 */

 

  }

  PIT.CH[1].TFLG.B.TIF = 1;   /* CLear PIT 1 flag by writing 1 */

}

 

 

void SwIrq4ISR(void) {

  SWirq4Ctr++;  /* Increment interrupt counter */

  INTC.SSCIR[4].R = 1;  /* Clear channel's flag */

}

 

So,I want to know when does MPC5604P enter the function Pit1ISR and SwIrq4ISR ? If I want to light a led when an interrupy happens,where should I add code "SIU.GPDO[52].B.PDO = 0"?

标签 (1)
0 项奖励
回复
1 回复

896 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

as I can see in the code, Pit1ISR should be triggered each 1ms. Each even Pit1ISR should then trigger software interrupt SwIrq4ISR - that means this one will be triggered each 2ms. Now it depends what you want to do... Just toggle GPIOs in both interrupt handlers, connect oscilloscope to GPIOs and watch the result...

Regards,

Lukas

0 项奖励
回复