2014-05-01 12:32 AM
Hi Guys:
May I ask how to distinguish the two sets of UART1 in STM8L151 ? There are UART1_TX = Port A2 UART1_Rx = Port A3 or UART1_TX = Port C3 UART1_Rx = Port C2 I confused about how the STM8L know I am using which set of them? Thx. #s2014-05-01 02:34 AM
Hi
I do not think you understand. There is only 1 UART1. You can route the pins to 2 alternate sets of pins, as you have listed. There is however ONLY ONE UART1. Routing to both sets of pin at the same time will cause undefined behavior. Trying to connect 2 RS232 device to the same UART through 2 sets of pins : again behaviour undefined and could cause damage!2014-05-01 04:43 PM
dear sir:
Thx for ur reply. Now I know there is only one UART1 module in STM8L with different port that u can remap to use. following is my code, but still can't work, pls help me: CLK_PeripheralClockConfig (CLK_Peripheral_USART1, ENABLE); USART_DeInit(USART1);USART_Init(USART1, 9600, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Tx);
USART_Cmd (USART1, ENABLE); SYSCFG_REMAPPinConfig ( REMAP_Pin_USART1TxRxPortA, ENABLE ); USART_SendData8(USART1, 0x41); while(!USART_GetFlagStatus (USART1, USART_FLAG_TXE)); while(1); Thx again.Hi
I do not think you understand. There is only 1 UART1. You can route the pins to 2 alternate sets of pins, as you have listed. There is however ONLY ONE UART1. Routing to both sets of pin at the same time will cause undefined behavior. Trying to connect 2 RS232 device to the same UART through 2 sets of pins : again behaviour undefined and could cause damage!2014-05-02 01:23 AM
Hi
Sorry but I work on the STM32 series but I did a quick scan through the data sheet and reference manual. In the reference manual, it says that the IO pin can be set to alternate function via the option bytes.2014-07-22 06:16 PM
Hi,
first, make sure you properly configure GPIO pins, PA2 as output, PA3 input without interrupts and enable PushPull feature with GPIO_ExternalPullUpConfig, then Remap, initialize USART and finally enable it.Erick