AnsweredAssumed Answered

emios MPC5634M can I use counter bus

Question asked by monica bagade on Mar 17, 2017
Latest reply on Mar 17, 2017 by monica bagade

I am trying to learn EMIOS module for MPC 5634M for all modes of operation. In this Initially I have tried use of Bus A and internal counter to drive the unifeid channel. ITS working propely. Now, I am trying to use counter bus B, C, D to drive the channel by selecting EMIOS.CH[10].CCR.B.BSL = 0x1 but its not working. Can anyone tell me what are the other settings require to use this mode. Also can I use use internal counter by selecting EMIOS.CH[10].CCR.B.BSL = 0x3 for other channel while using EMIOS.CH[10].CCR.B.BSL = 0x1 mode for some different channel in the same program.

This is my code.

/ Initilization of EMIOS

void initEMIOS(void) {
 
  EMIOS.MCR.B.GPRE= 63;   /* Divide 64 MHz sysclk by 63+1 = 64 for 1MHz eMIOS clk*/
  EMIOS.MCR.B.GPREN = 1; /* Enable eMIOS clock */
  EMIOS.MCR.B.GTBE = 1;   /* Enable global time base */
  EMIOS.MCR.B.FRZ = 1;    /* Enable stopping channels when in debug mode */
   //EMIOS.MCR.B.ETB = 0;
}

// Channel 23 for modulous counter

void initEMIOSch23(void) {        /* EMIOS CH 23: Modulus Up Counter */
  EMIOS.CH[23].CADR.R = 999;     /* Period will be 999999+1 = 1000000 clocks (1 sec) */
  EMIOS.CH[23].CCR.B.MODE = 0x50; /* MPC551x, MPC563x: Mod Ctr Bufd (MCB) int clk */
  EMIOS.CH[23].CCR.B.BSL = 0x3;   /* Use internal counter */
  EMIOS.CH[23].CCR.B.UCPRE=0;   /* Set channel prescaler to divide by 1 */
  EMIOS.CH[23].CCR.B.FREN = 1;    /* Freeze channel counting when in debug mode */
  EMIOS.CH[23].CCR.B.UCPREN = 1;  /* Enable prescaler; uses default divide by 1 */
}

//Channel 10 for OPWMB

void initEMIOSch10(void) {         /* EMIOS CH 0: Output Pulse Width Modulation */
  EMIOS.CH[10].CADR.R = 250 ;       /* Leading edge when channel counter bus=250*/
  EMIOS.CH[10].CBDR.R = 500;       /* Trailing edge when channel counter bus=500*/
  EMIOS.CH[10].CCR.B.BSL = 0x1;   /* Use counter bus A (default) */
  //EMIOS.CH[14].CCR.B.UCPRE = 1;     // internal prescaler of Unified Channel=1
  //EMIOS.CH[14].CCR.B.UCPREN = 1;   // internal prescaler of Unified Channel enable
  EMIOS.CH[10].CCR.B.EDPOL = 1;   /* Polarity-leading edge sets output/trailing clears*/
  EMIOS.CH[10].CCR.B.MODE = 0x60;  /* MPC551x, MPC563x: Mode is OPWM Buffered */
  SIU.PCR[189].R = 0x0600;        /* Initialize pad for eMIOS chan. 0 output */
}

/Channel 14 for OPWFMB

void initEMIOSch14(void) {         /* EMIOS CH 0: Output Pulse Width Modulation */
  EMIOS.CH[14].CADR.R =  499;       /* Leading edge when channel counter bus=250*/
  EMIOS.CH[14].CBDR.R = 999;       /* Trailing edge when channel counter bus=500*/
  EMIOS.CH[14].CCR.B.UCPRE = 1;     // internal prescaler of Unified Channel=1
  EMIOS.CH[14].CCR.B.UCPREN = 1;   // internal prescaler of Unified Channel enable
  EMIOS.CH[14].CCR.B.EDPOL = 1;   /* Polarity-leading edge sets output/trailing clears*/
  EMIOS.CH[14].CCR.B.MODE = 0x58;  /* MPC551x, MPC563x: Mode is OPWM Buffered */
  SIU.PCR[193].R = 0x0600;        /* Initialize pad for eMIOS chan. 0 output */
}

Outcomes