eMIOS0 and ADC0 together in single program (Clock gating Problem?) on TRK-MPC5606B

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

eMIOS0 and ADC0 together in single program (Clock gating Problem?) on TRK-MPC5606B

623 Views
akshaydaga
Contributor III

I want to us eMIOS0 to generate PWM and want to change the duty Cycle of the PWM signal as per ADC0 input.

My program work perfectly fine while using eMIOS0 only but

When ever add following lines of code (for Clock gating for ADC0 peripheral) in "void InitModesAndClks(void)" function, My program stops working completely.

when I comment these 2 line then program starts working again (eMIOS module only)

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

  ME.PCTL[32].R = 0x01; // MPC56xxB/P/S ADC 0: select ME.RUNPC[1]

  ME.PCTL[68].R = 0x01; // MPC56xxB/S SIU: select ME.RUNPC[1] 

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

Please help me in using both eMIOS0 and ADC0 in same program.

"void InitModesAndClks(void)" function is as follows:

 

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

/* Enter RUN0 with PLL as sys clk (64 MHz) with 8 MHz crystal reference. */
void InitModesAndClks(void) {
      ME.MER.R = 0x0000001D;          /* Enable DRUN, RUN0, SAFE, RESET modes */
      CGM.FMPLL_CR.R = 0x01200100;    /* 8MHz xtal: Set PLL0 to 64 MHz */
      ME.RUNPC[0].R = 0x000000FE; /* enable peripherals run in all modes */
      ME.RUN[0].R = 0x001F0074;       /* RUN0 cfg: IRCON,OSC0ON,PLL0ON,syclk=PLL */

      //These 2 lines creates problem

      //ME.PCTL[32].R = 0x01; /* MPC56xxB/P/S ADC 0: select ME.RUNPC[1] */

      //ME.PCTL[68].R = 0x01; /* MPC56xxB/S SIU: select ME.RUNPC[1] */  

     

      /* Mode Transition to enter RUN0 mode: */
      ME.MCTL.R = 0x40005AF0;         /* Enter RUN0 Mode & Key */
      ME.MCTL.R = 0x4000A50F;         /* Enter RUN0 Mode & Inverted Key */
      while (ME.GS.B.S_MTRANS) {} ;    /* Wait for mode transition to complete */
      while(ME.GS.B.S_CURRENTMODE != 4) {}; /* Verify RUN0 is the current mode */

}

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

Original Attachment has been moved to: eMIOS0_ADC0_APDaga.rar

Labels (1)
0 Kudos
1 Reply

524 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Yes, it cannot work as the clock is gated to the SIU and ADC if mentioned lines are used.

With the ME.PCTL[32].R = 0x01; you select configuration defined in RUNPC[1]. However this register is not set in your code and it is cleared by default, means clock is gated in all modes.

Only RUNPC[0] is set in your code (enable clocks in all modes), thus if ME.PCTL[32].R is not programmed, by default is it cleared and so RUNPC[0] configuration is selected.

BR, Petr

0 Kudos