2022-11-09 07:28 AM
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 .
Solved! Go to Solution.
2022-11-13 11:22 AM
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.
2022-11-13 11:22 AM
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.
2022-11-13 10:12 PM
Hi Michal,
thank you for the answer.