2018-03-29 01:06 AM
Hello Everyone!
I am trying to configure LIN_FLEX_0 channel for UART communication. Following is my code for the configuration.
&sharpdefine LIN_CH0 LINFLEXD_0
LIN_CH0.LINCR1.B.INIT=1; /* Put LIN into INIT mode to configure */
LIN_CH0.UARTCR.B.UART=1; /* UART enable */
LIN_CH0.UARTCR.B.ROSE=1;
LIN_CH0.UARTCR.B.OSR=4;
LIN_CH0.LINIBRR.R=200; /* 100 kbits Buad Rate is selected . 80Mbits/(LINIBRR*OSR) */
LIN_CH0.UARTCR.B.WL0=1; /* Receive 8 bits */
LIN_CH0.UARTCR.B.PCE=0; /* Receive 8 bits without parity bit */
LIN_CH0.UARTCR.B.RXEN=1; /* Receiver Enable */
LIN_CH0.UARTCR.B.WL1=1; /* Receive 8 bits */
LIN_CH0.UARTCR.B.RFBM=0; /* Rx Buffer Mode */
LIN_CH0.UARTCR.B.RDFL_RFC=3; /* 4 bytes will be received */
LIN_CH0.UARTCR.B.WLS=0; /* Special Word Length in UART is disabled */
LIN_CH0.LINCR1.B.SLEEP=0;
LIN_CH0.UARTSR.R=0xFFFF; /* Clearing UARTSR register.*/
LIN_CH0.LINIER.B.FEIE=1;
LIN_CH0.LINIER.B.DRIE=1;
LIN_CH0.LINIER.B.BOIE=1;
LIN_CH0.LINIER.B.SZIE=1;
LIN_CH0.LINCR1.B.INIT=0; /* INITIAL MODE is finished to enter into NORMAL Mode */
The problem is that when i Run this code and check LINFLEXD_0_UARTCR Register then still it show some default values and does not initialize according to my code. Please check the attached figure for UARTCR register.
Can anyone please help me in initializing the LIN_FLEX_0 for UART communication..
#uart #initialization #st322018-03-29 06:33 AM
Hello Abdul ,
Have you enable PCTL for LINFLEX_0 ?
for your information , on SPC5Studio Tools Suite , there is nice example of LINLEX configuration.
(Cf Serial Applications)
Best regards
Erwan
2018-08-09 06:43 AM
You says 100kbps for baud rate but as i know LIN Bus works max 20kbps