2018-07-15 11:00 PM
Hi I want to design CAN-LIN converter. I chose the STM32F091CC microcontroller for its LIN support. Up to this time I coded the CAN communication in the microcontroller.
I have basic information about LIN. I want to integrate this into my microcontroller system. What I want to know is where do I start, are there any example studies on this subject?
#stm32f103-lin #lin-protocol #lin #lin-tranceiver #lin-stm32f4 #232-lin-converter2018-07-16 05:58 AM
in the reference manual p711:
For code example refer to the Appendix section A.19.6: USART LIN mode code example.
do you want multidrop ? or peer to peer ?
mutidrop is usually RS485.
how many nodes on the Lin network ?
2018-08-08 10:33 PM
Hello T.J i looked that chapter and that chapter refers to initalization part of the LIN Bus. But i want to transmit and receive LIN message but i cant see any function for this. Okey mcu datasheet tells me the transmit is same as uart transmit. But i dont know how to receive LIN messages.
2018-08-10 06:00 PM
in the F091, Lin is supported by Usart1,2,3
The LIN mode is selected by setting the LINEN bit in the USART_CR2 register. In LIN
mode, the following bits must be kept cleared:
• STOP[1:0] and CLKEN in the USART_CR2 register,
• SCEN, HDSEL and IREN in the USART_CR3 register.
USART LIN mode code example
/* (1) oversampling by 16, 9600 baud */
/* (2) LIN mode */
/* (3) 8 data bit, 1 start bit, 1 stop bit, no parity,
reception and transmission enabled */
USART1->BRR = 480000 / 96; /* (1) */
USART1->CR2 = USART_CR2_LINEN | USART_CR2_LBDIE; /* (2) */
USART1->CR1 = USART_CR1_TE | USART_CR1_RXNEIE
| USART_CR1_RE | USART_CR1_UE; /* (3) */
/* Polling idle frame Transmission */
while ((USART1->ISR & USART_ISR_TC) != USART_ISR_TC)
{
/* add time out here for a robust application */
}
USART1->ICR |= USART_ICR_TCCF; /* Clear TC flag */
USART1->CR1 |= USART_CR1_TCIE; /* Enable TC interrupt */
2018-08-10 06:15 PM
Where is your LIN reference manual ?
did you see the appnote AN1278 ?
LIN (LOCAL INTERCONNECT NETWORK) SOLUTIONS
its 2002 vintage.
There is some sample code in the appnote
looking in the reference manual for LIN registers.
Usart CR2 Page 735
Bit 14 LINEN: LIN mode enable
This bit is set and cleared by software.
0: LIN mode disabled
1: LIN mode enabled
The LIN mode enables the capability to send LIN Sync Breaks (13 low bits) using the SBKRQ bit in the USART_RQR register, and to detect LIN Sync breaks.
This bit field can only be written when the USART is disabled (UE=0).
Note: If the USART does not support LIN mode, this bit is reserved and forced by hardware to ‘0’.
Please refer to Section 27.4: USART implementation on page689.
I have never worked with LIN.
but You can make your own driver.
The best way forward is to buy a LIN transceiver and set it to transmit ev3ery second.
Work on the receiver first, then do your transmitter.
then increase the packet rate to maximum.. for further testing