cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S001J3 UART RECEIVING PROBLEM

nraj
Associate II

Hi All,

I am using stm8s001j3 controller, PA1 and PA3 are using as a UART communication by using Remapping. i am able to send the data but unable to receive data. UART configuration is

   GPIO_DeInit(GPIOD);

GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_PU_NO_IT);

  GPIO_Init(GPIOA, GPIO_PIN_3,

      GPIO_MODE_OUT_OD_HIZ_FAST);

 UART1_Init((uint32_t)9600, UART1_WORDLENGTH_8D,UART1_STOPBITS_1, UART1_PARITY_NO,

          UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);

 /* Enable the UART Receive interrupt: this interrupt is generated when the UART

  receive data register is not empty */

 UART1->BRR1 = 0x68;

  UART1->CR2 = 0x2C;

 /* Enable UART */

 UART1_Cmd(ENABLE);

enableInterrupts();

INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)

{

 /* In order to detect unexpected events during development,

   it is recommended to set a breakpoint on the following instruction.

 */

 /* Read one byte from the receive data register and send it back */

 if(UART1->SR & 0x20)

 {

  char temp = UART1->DR;

    while(!(UART1->SR & 0x80));

    UART1->DR = temp;

 }

}

OR

I tried below logic in main while(1) loop

if(UART1_GetFlagStatus(UART1_FLAG_RXNE) != 0)

   {

     ch = UART1_ReceiveData8();

     UART1_ClearFlag(UART1_FLAG_RXNE);

    while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET)

    {

    }

     UART1_SendData8(ch + 0x30);

   }

 Anyone any idea about UART please share .

1 ACCEPTED SOLUTION

Accepted Solutions

Datasheet claims:

"By remapping UART1_TX (AFR0=1 and AFR1=1) to PA3 the UART1_RX alternate function on PD6 becomes unavailable"

That is probably root of your problem.

View solution in original post

2 REPLIES 2

Datasheet claims:

"By remapping UART1_TX (AFR0=1 and AFR1=1) to PA3 the UART1_RX alternate function on PD6 becomes unavailable"

That is probably root of your problem.

Hi Michal,

thank you for the answer.