2014-10-28 03:27 AM
Hi,
I am trying to change to HAl library from STD lib. One of the task is port modbus code. I want to receive data, however size is unknown and is time critical (2.5 chars depending on baud rate).typedef struct
{ uint8_t au8RxBuf[UART_BUF_RX_SIZE]; uint8_t au8TxBuf[UART_BUF_TX_SIZE]; uint16_t u16RxBufCnt; uint16_t u16TxBufCnt; uint8_t u8TxComplete; uint8_t u8Error; uint8_t u8RxStatus; uint8_t u8TxStatus; }uart_data_s;uart_data_s uart_data_485B;
void bsp_uart_485B_ISR(void)
{ uint8_t u8dummy; static uart_data_s *ptr; static uint16_t u16ISRTxCnt = 0; ptr = &uart_data_485B;// Receive Section
if(USART_GetITStatus(usart_conf[UART_485B].usart_peri, USART_IT_RXNE) != RESET) { bsp_GenTimer_Load(MB_PKT_SEAL_GEN_TIMERB, mbPktSealTimeout[UART_19200_BAUD]); // Maximum Timeout between bytes to seal packet u8dummy = USART_ReceiveData(usart_conf[UART_485B].usart_peri); // Read one byte from the receive data register if (UART_BUF_STATUS_FREE == (uart_buf_status_e) ptr->u8RxStatus) { if(ptr->u16RxBufCnt < UART_BUF_RX_SIZE) ptr->au8RxBuf[ptr->u16RxBufCnt++] = u8dummy; // else Neglect As buffer is not free } }// Transmit section
if(USART_GetITStatus(usart_conf[UART_485B].usart_peri, USART_IT_TXE) != RESET) { if(u16ISRTxCnt < ptr->u16TxBufCnt) USART_SendData(usart_conf[UART_485B].usart_peri, ptr->au8TxBuf[u16ISRTxCnt++]); // Send One Byte else { ptr->u8TxComplete = UART_STATUS_FREE; // Transmit Complete u16ISRTxCnt = 0; ptr->u16TxBufCnt = 0; bsp_GenTimer_Load(MB_TX_COMPLETE_TIMERB,mbPktSealTimeout[M530S_RS485B_DFLT_BAUD]); USART_ITConfig(usart_conf[UART_485A].usart_peri, USART_IT_TXE, DISABLE); // Disable Tx Interrupt } } }Note: bsp_GenTimer_Load will load timeout in software tiimers and on TImeout seal the packet or post the semaphore.
Also I am trying to check UART_Hyperterminal_IT example provided with HAL.
This example receives 10 bytes of data however if I send 15 bytes in one go code loops inside HAL_UART_IRQHandler in UART_Transmit_IT with huart->State as HAL_UART_STATE_READY. Is there any bug with this HAL lib code. Also Can you provide me the pending bug list with HAL. I have increased RxBuffer size to 32 bytes howevr receiving 10 bytes only through HAL_UART_Receive_IT. Is there any known bugs list with HAL.Regards
Chetan
2014-10-28 05:44 AM
Hi Chetan,
Would you mind giving a little more information about the STM32Cube_FW package you are using ? That would help more easily figure out where a problem could be.Regards,Heisenberg.2014-10-28 05:52 AM
2015-01-22 02:08 AM
Hi Chetan,
The is released with the new STM32F4_HAL_Driver V1.2.0. The following updates are implemented on the HAL UART driver:2015-01-23 12:35 AM
Hi Heisenberg,
when will the new Cube driver be released for the STM32F2xx? Will it be able to handle non-blocking reception of USART messages with unknown lenght? Ralph2016-01-24 09:29 AM
Hi Heisenberg,
Is the STM32F4_HAL_Driver V1.2.0 able to trig a recieve interrupt for each single char that is recieved?What code lines do I need to add/modify to make the ST's example code''UART_TwoBoards_ComIT'' for stm32F4 Discovery to work with recieve interrupt for each char?RegardsMagnus2016-01-24 10:46 AM
The STM32 USART is inherently only capable of dealing with a byte at a time, based on it's buffering/design. The use of DMA may mask this, but any interrupt/callback based method is going to get an RXNE type interrupt as each byte arrives.