Problem in using UART+linflex in Mpc5606b

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

Problem in using UART+linflex in Mpc5606b

1,223 Views
akhilmalik
Contributor II

hello sir,

i am using uart using linflex on mpc5606b in codewarrior

data is not being transmitted  ??

BELOW IS MY CODE

please reply ASAP

 

THANKYOU,,,

 

 

 

 

#include "MPC5606B.h"

 

 

void initModesAndClock(void);

void config_PORT_E(void);

void initPeriClkGen(void);

void init_LIN0(void);

void enableIrq(void);

void disableWatchdog(void);

 

int main (void) {

initModesAndClock(); /* Initialisation of the device */

config_PORT_E(); /* Configuration of GPIO */

initPeriClkGen();

LINFLEX_0.LINSR.B.DTF = 1;

SIU.GPDO[68].B.PDO=1;//for external 5V

enableIrq();

disableWatchdog();

init_LIN0();

 

for(;;)

{

  

  LINFLEX_0.BDRL.B.DATA0=0x11;

    LINFLEX_0.LINCR2.B.DTRQ = 1;

  while(LINFLEX_0.LINSR.B.DTF!=1){};

  

  SIU.GPDO[69].B.PDO=1;

  

  LINFLEX_0.LINSR.B.DTF = 1;

}

}

void config_PORT_E(void)

{

SIU.PCR[68].R = 0x0200;

SIU.PCR[69].R = 0x0200;

SIU.PCR[18].R = 0x0604;//LIN_0TX

}

 

 

void initPeriClkGen(void) {

 

 

  CGM.SC_DC0.R=0x80;      

}

void initModesAndClock(void) {

ME.MER.R = 0x0000001D;

ME.RUN[0].R = 0x001F0070;//16MHz

ME.RUNPC[0].R = 0x00000010;

ME.PCTL[68].R=0x00;

ME.PCTL[48].R=0x00;

ME.MCTL.R = 0x40005AF0;

ME.MCTL.R = 0x4000A50F;

while (ME.GS.B.S_MTRANS == 1) {}

while (ME.GS.B.S_CURRENTMODE != 4) {}

 

 

}

void init_LIN0(void)

{

  LINFLEX_0.LINCR1.B.INIT = 1;

  while (0x1000 != (LINFLEX_0.LINSR.R & 0xF000)) {}

 

  LINFLEX_0.UARTCR.B.UART = 1;

  LINFLEX_0.LINCR1.B.LBKM = 1;

  LINFLEX_0.UARTCR.R = 0x00000011;   

  LINFLEX_0.LINIBRR.B.DIV_M= 104; //Baud Rate @ 16MHZ = 9600

  LINFLEX_0.LINFBRR.B.DIV_F = 3;  //Baud Rate @ 16MHZ = 9600

}

void disableWatchdog(void) {

  SWT.SR.R = 0x0000c520;    

  SWT.SR.R = 0x0000d928;

  SWT.CR.R = 0x8000010A; 

}

void enableIrq(void)

{

  INTC.CPR.B.PRI=0;

  asm("wrteei 1");

}

Labels (1)
0 Kudos
2 Replies

698 Views
akhilmalik
Contributor II

hi

it helped.

thanks :smileyhappy:

0 Kudos

698 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

attached you will find two working examples.

UART is also used in this example:

Example MPC5604B PinToggleStationery CW210

Regards,

Lukas

0 Kudos