MPC5644a PIT interrupt

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

MPC5644a PIT interrupt

1,197 Views
stanleyli
Contributor II

Hi,

I am developing PIT interrupt on mpc564xa kit.

The problem is that PIT interrupt never happen.

Can someone help me solve this?

TKS.

#include "MPC5644A.h"

void Pit0ISR(void);

void initINTC(void) {

/* Use one the following two lines */

/*INTC.MCR.B.HVEN_PRC0 = 1;*//* MPC551x: initialize Proc'r 0 for HW vector mosde */

  INTC.MCR.B.HVEN = 1;       /* MPC555x: initialize Proc'r 0 for HW vector mosde */

}

void enableIrq(void) {

/* Use one of the following two lines to lower the INTC current priority */

//INTC.CPR_PRC0.B.PRI = 0;   /* MPC551x: Lower INTC's current priority */

  INTC.CPR.B.PRI = 0;       /* MPC555x: Lower INTC's current priority */

   asm(" wrteei 1");           /* Enable external interrupts */

}

int ii =0;

void Pit0ISR(void) { 

  ii++;

  PIT.TIMER[0].TFLG.B.TIF = 1;    /* MPC56xxP/B/S: CLear PIT 1 flag by writing 1 */ 

}

int main(void) {

  volatile int i = 0;

  FMPLL.ESYNCR1.B.EMODE = 1;

  FMPLL.ESYNCR1.B.CLKCFG = 7;

  FMPLL.ESYNCR1.B.EPREDIV = 8;

  FMPLL.ESYNCR1.B.EMFD = 80;

    FMPLL.ESYNCR2.B.ERFD = 4;

    //while (FMPLL.SYNSR.B.LOCK != 1) {};

    SIU.SYSDIV.B.SYSCLKDIV = 1;

   

   

    //FMPLL.ESYNCR1.B.CLKCFG = 0X7;       /* Change clk to PLL normal mode from crystal */ 

    //FMPLL.SYNCR.R = 0x16080000;         /* 8 MHz xtal: 0x16080000; 40MHz: 0x46100000 */

    //while (FMPLL.SYNSR.B.LOCK != 1) {}; /* Wait for FMPLL to LOCK  */

    //FMPLL.SYNCR.R = 0x16000000;         /* 8 MHz xtal: 0x16000000; 40MHz: 0x46080000 */   

    //SIU.SYSCLK.B.SYSCLKSEL = 2;

    //----------disable watchdog--------------

    SWT.SR.R = 0xC520;

    SWT.SR.R = 0xD928;

    SWT.MCR.B.WEN = 0;

    //-----------------------------------------

   

    PIT.PITMCR.B.MDIS = 0;

    PIT.TIMER[0].LDVAL.R = 0x00FF; // setup timer 1 for 256000 cycles

    PIT.TIMER[0].TCTRL.B.TIE = 1;

    PIT.TIMER[0].TCTRL.B.TEN = 1;

    INTC.PSR[301].R = 1; //for timer0

    initINTC();         /* Initialize INTC for hardware vector mode */

    INTC_InitINTCInterrupts();    // Init interrupts     

    INTC_InstallINTCInterruptHandler(Pit0ISR, 301, 1);

    enableIrq();

  /* Loop forever */

  for (;;) {

    i++;

  }

}

Tags (1)
0 Kudos
Reply
1 Reply

724 Views
petervlna
NXP TechSupport
NXP TechSupport

I am missing your INTC_InitINTCInterrupts and INTC_InstallINTCInterruptHandler functions. So I can only guess without full project what is wrong.

Below are few steps you can check.

First of all:

  1. Check if your flag TIF is set when PIT counts to 0.

I see that you enable EE in core. That’s correct.

  1. When your PIT set the flag TIF = 1 the interrupt handler is called.
  2. The upper half of the interrupt vector prefix register (IVPR) is added to an offset, which corresponds to the peripheral or software interrupt source that caused the interrupt request. The offset matches the value in the Interrupt Vector field, INTC_IACKR[INTVEC]. So do you see INTC_IACKR[INTVEC] = 301 in decimal when TIF is set?
0 Kudos
Reply