MPC5605B : EMIOS_0.CH[23] under SAICMode

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

MPC5605B : EMIOS_0.CH[23] under SAICMode

691 Views
maoyuanluo
Contributor III

Hi all:

   Recently I have a new requirement which to detect PWM input from outside.

   Normally, FREQ = 10Hz, duty = 50%

   Crash, FREQ = 250Hz, duty = 50% (Only 10 cycles are generated when crash is happen)

   I use MPC5605B(144 Pin) PF[6] pin to detect the wave.

   Test code is as follow:

INTC.PSR[152].R = 0x0a;
/* EMIOS_0_GFR[F22,F23] Priority is: 0 */

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

uint32_t IntcIsrVectorTable[] = {

...

(uint32_t)&pwm_isr,    /* Vector - 152    interrupt_handler*/

...

};

void initEMIOS_0(void) {

EMIOS_0.MCR.B.GPRE= 63; /* Divide 64 MHz sysclk by 63+1 = 64 for 1MHz eMIOS clk*/
EMIOS_0.MCR.B.GPREN = 1; /* Enable eMIOS clock */
EMIOS_0.MCR.B.GTBE = 1; /* Enable global time base */
//EMIOS_0.MCR.B.FRZ = 1; /* Enable stopping channels when in debug mode */
EMIOS_0.UCDIS.R = ~(1 << 23);
}

void initEMIOS_0ch23(void) { /* EMIOS 0 CH 23: SAIC */   
EMIOS_0.CH[23].CCR.B.BSL = 0x0; /* Use counter bus A (default) */
EMIOS_0.CH[23].CCR.B.EDPOL = 1; /* capture on rising edge */
EMIOS_0.CH[23].CCR.B.FEN = 1; /* flag generates and interrupt */
//EMIOS_0.CH[23].CSR.R = 0x00000001; /* Clear eMIOS ch23 FLAG flag by writing 1 */
EMIOS_0.CH[23].CCR.B.MODE = 0x02; /* Mode is SAIC */
SIU.PCR[86].R = 0x0500; /* MPC56xxS: Assign EMIOS_0 ch 23 to pad */
}

void pwm_init(void)

   initEMIOS_0(); /* Initialize eMIOS 0 to provide 1 MHz clock to channels */
   initEMIOS_0ch23(); /* Initialize eMIOS 0 channel 23 as modulus counter*/

   static unsigned long i = 0;

   while (1) {
      i ++;
   }

}

volatile unsigned long edge;

void pwm_isr(void)
{
edge = EMIOS_0.CH[23].CADR.R; /* save counter bus value when capture occured */

if (1 == EMIOS_0.CH[23].CSR.B.FLAG)
   EMIOS_0.CH[23].CSR.B.FLAG = 1; /* Clear eMIOS ch23 FLAG flag by writing 1 */
}

I search the question in nxp forum and see the reference example,but can‘t solve my problem.

Two question I want to solve:

1.If EMIOS_0.CH[23].CCR.B.FEN is set to 0, can i polling the FLAG to judge the event has happend?

2.In my test example, I used another MCU to simulate the PWM wave and the frequency change with pressed the key.

   But this code can't enter the interrupt routine and the FLAG bit is not asserted.

Can you help me to solve my queation?

Labels (1)
0 Kudos
1 Reply

483 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

1. yes, you can use the FLAG for SW polling

2. you also need to set respective PSMI register to route pin to the eMIOS module

pastedImage_1.png

SIU.PSMI[24].R = 0x2;           /* MPC56xxB: Select PCR[86] for eMIOS ch 23 Input */

Also you should select internal counter for the ch23 (BSL=3) and enable the prescaler (UCPREN=1).

BR,

Petr

0 Kudos