2015-12-29 07:26 AM
I
am developing application for stm32l0 using CUBEmx and keil, my intention is totransmit command to modem and receive
response , so I have used to Transmit data and receive data through UART RX DMA.
I am able to transmit data through hlpuart1 ,
huart2
successfully , but unable to getHAL_UART_TxCpltCallback on data reception ,
I have enabled breakpoint and checked Rx and Tx buffer , as expected transmitted data in TxBuffer
received in RXBuffer, But callback has not serviced.Main loop
if(current_state == IDLE){
current_state = TRANSMITTING;
HAL_UART_Receive_DMA(&hlpuart1,RxBuffer,6);
HAL_UART_Transmit(&hlpuart1,TxBuffer,sizeof(TxBuffer),1000);
HAL_Delay(5000);
HAL_UART_Transmit(&huart2,RxBuffer,6,1000);
while(current_state != RECV_READY) (Control stalled here because current stare not cleared by
HAL_UART_TxCpltCallback
)
{
}
HAL_UART_Transmit(&huart2,TxBuffer,6,1000);
current_state = IDLE;
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
current_state = RECV_READY;
}
Any one can throw some light where I made mistake
#stm32l0 #uart2-dma-interrupt2015-12-29 08:47 AM
Hi murugesan.kudiarasu,
HAL_UART_TxCpltCallback is invoked when you are in interrupt mode or DMA mode.In polling mode using HAL_UART_Transmit, this callback is not needed.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-12-29 09:57 PM
Hi Mayla,
Thank for correcting me, By mistake i have used HAL_UART_TxCpltCallback instead of HAL_UART_RxCpltCallback , already configured DMA to receive data Through LPUART_RX in CubeMX, Even now the callback is not serving on receive complete.2015-12-29 10:00 PM
Hi ,
I have attached the latest source (main.c) file ________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1CZ&d=%2Fa%2F0X0000000bjq%2F.jxak7oMpny8nxhMqb0TgpSr10nkDDeFEaf.1rzosqU&asPdf=false2015-12-30 02:15 AM
Himurugesan.kudiarasu,
Is theUARTx_IRQHandler added in your file stm32l0xx_it.c file:void
USARTx_IRQHandler(
void
)
{
HAL_UART_IRQHandler(&UartHandle);
}
-Mayla-
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-12-30 09:11 PM
Hi Mayla,
Yes, its there in the file, please find the attached files stm32l0xx_it.c and main .c ________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1CU&d=%2Fa%2F0X0000000bjo%2F.6tZtqd87hJTJS3b5qKXSUS_Akty7oMAlznFx2ClWNM&asPdf=falsestm32l0xx_it.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I12G&d=%2Fa%2F0X0000000bjn%2F2VUhMW6CsLJ8QcsQJKh9aGswUNnGsqW7EzMebn3ciA4&asPdf=false2015-12-31 04:51 AM
Expectations dictate that this should be volatile
uart_current_state current_state = IDLE;