cancel
Showing results for 
Search instead for 
Did you mean: 

SPC570S50E1 UART Confinguration

Abdul Basit Khan
Associate
Posted on March 29, 2018 at 10:06

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 #st32
2 REPLIES 2
Erwan YVIN
ST Employee
Posted on March 29, 2018 at 15:33

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

in mozbek we trust
Associate II

You says 100kbps for baud rate but as i know LIN Bus works max 20kbps