2021-12-01 09:18 AM
uint8_t rx_buffer[32], rx_flag, rx_index, rx_data, RxData[32];
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance==USART1)
{
//if the data is not being received, clear the buffer
if(rx_index ==0)
{
for (int i=0; i<20; i++)
{
rx_buffer[i]=0;
}
}
//if the character received is other than 'enter' ASCII13, save the data in buffer
if(rx_data!=13)
{
rx_buffer[rx_index++]=rx_data;
}
else
{
rx_index=0;
rx_flag=1; // turn the rx_flag 'ON'
HAL_UART_Transmit(&huart1, rx_buffer, sizeof(rx_buffer), 100); // transmit the data via UART
}
HAL_UART_Receive_IT(&huart1, &rx_data, 1); // restart the interrupt reception mode & receive only 1 char at a time!
}
}
I declared a 32byte rx_buffer[], when I send more than 32 Bytes, the board couldn't receive any more serial data through interrupts! Attached my sample callback function and code inside that portion!
Regards,
Thangz
Solved! Go to Solution.
2021-12-02 09:54 AM
stm32l1xx_hal_msp_template.c file is not expected to be compiled. Maybe you added it the the list of objects in your projects ?
However, if you are using CubeMx, the generated stm32l1xx_hal_msp.c file should contain a valid HAL_MspInit() body (for example all peripheral clocks are to be enabled here). Without this function body, it can't work.
Could you use the previous content of HAL_MspInit() function when you were able to receive some chars ?
2024-08-27 11:51 PM
@Guenael Cadier , @TMuka.1 , @TDK
I find the solution the Guenael Cadier suggested (UART DMA circular buffer ReceptionToIdle) exactly what I am leaning to with my application (variable length commands) and I will be moving now towards the implementation.
I cannot see in the Examples\UART\ folder the UART_ReceptionToIdle_CircularDMA example for STM32L05x (CubeIDE 1.12.1)
Actually there is no implementation of HAL_UARTEx_ReceiveToIdle_DMA for STM32L0 family in stm32l0xx_hal_uart.
Can you please indicate where I could find/download examples? Or does L0 family not support this function?
Regards
2024-08-28 12:09 AM
Hi @_alaBaster
I think ReceiveToIdle API should be available in latest STM32L0 HAL drivers version (please check in stm32l0xx_uart_ex.c). If not, maybe you could have a look in latest version of STM32L0 HAL drivers available on github here .
API prototypes are present in stm32l0xx_hal_driver/Src/stm32l0xx_hal_uart_ex.c
Regards
2024-08-28 07:02 AM
There aren't any examples in the L0, but you can adapt the examples for another family.
The function definition is here:
2024-08-29 03:04 AM
Hi @Guenael Cadier got it, thanks. I was looking only at stm32l0xx_hal_uart.c
Kind regards
2024-08-29 03:05 AM
ok great, thanks. Now it is time to dive into it! 🙂