AnsweredAssumed Answered

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

Question asked by Akshay Daga on Apr 18, 2016

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

Outcomes