cancel
Showing results for 
Search instead for 
Did you mean: 

how to distinguish the two sets of UART1 in STM8L151

firstjacki
Associate
Posted on May 01, 2014 at 09:32

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.

#s
4 REPLIES 4
chen
Associate II
Posted on May 01, 2014 at 11:34

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!

firstjacki
Associate
Posted on May 02, 2014 at 01:43

    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!

chen
Associate II
Posted on May 02, 2014 at 10:23

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.

eccker
Associate
Posted on July 23, 2014 at 03:16

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