Reputation: 1
I'm trying to read/write data via USART3 IRQ on STM32F405 (debug in CubeIDE) sending data is OK, however with receiving I've met the following problem:
Problem: STM32 catch interrupt if I send data from PC to stm, RXNE and IDLE flags are set, but if I make one step in debugger (still being in the handler) and perform operation that has nothing to do with clearing the flag - RXNE and IDLE flags are cleared! I don't understand how, so I can't perform any actions related to RXNE flag, because it's cleared without my commands.
Here is my initialization:
LL_USART_InitTypeDef USART_InitStruct = {0};
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
LL_APB1_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART3);
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
GPIO_InitStruct.Pin = USART1_TX_MB1_Pin|USART1_RX_MB1_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
USART_InitStruct.BaudRate = 9600;
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
LL_USART_Init(USART3, &USART_InitStruct);
LL_USART_ConfigAsyncMode(USART3);
LL_USART_Enable(USART3);
NVIC_SetPriority(USART3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
NVIC_EnableIRQ(USART3_IRQn);
Handler:
void USART3_IRQHandler(void)
{
uint8_t x = 0;
if (USART3->SR & (USART_SR_NE | USART_SR_FE | USART_SR_PE | USART_SR_ORE))
{
LL_USART_ClearFlag_FE(USART3);
LL_USART_ClearFlag_NE(USART3);
LL_USART_ClearFlag_ORE(USART3);
}
if (LL_USART_IsActiveFlag_RXNE(USART3))
x = LL_USART_ReceiveData8(USART3);
if (LL_USART_IsActiveFlag_TC(USART3))
{
LL_USART_TransmitData8(USART3, 0x55);
LL_USART_DisableIT_TC(USART3);
}
}
Upvotes: 0
Views: 645
Reputation: 1
So, the problem was in CubeIDE and breakpoints, initially breakpoint was at very first instruction in the handler. When I put breakpoint on line x = LL_USART_ReceiveData8(USART3);
- it worked. Shame on CubeIDE
Upvotes: -2