2018-11-04 04:48 AM
I am working with STM32429i-eval and try connect it to PC. I think that there are two mistakes at stm32f4xx_hal_uart.c.
Into
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
Instead of
if(huart->ErrorCode != HAL_UART_ERROR_NONE)
need
if(huart->ErrorCode == HAL_UART_ERROR_NONE)
and
into
static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart)
Instead of
if(huart->RxState == HAL_UART_STATE_BUSY_RX)
need
if(huart->RxState != HAL_UART_STATE_BUSY_RX)
After this corrections I connect to PC by over interrupt.
What you think about this?
PS STMCube .V1.21.0 / 23-February-2018
HAL Driver V1.7.4 / 02-February-2018
2018-11-04 11:55 AM
> After this corrections I connect to PC by over interrupt
In lines 831 and 1571?
It does not look like bugs. (though I prefer LL drivers for UARTs, not HAL).
-- pa
2018-11-05 01:31 AM
Not quite
in lines 1571 and 2375
I try receive byte over interrupt when port get it (without infinite loop for get bytes). My code is below. May be it is wrong, but if not made two my corrections bytes not be received.
I tested my code at 9600 and 115200 baud.
By the way. What is LL-driver? Could I get it ? Could I get example for used it ?
Becourse I see possible mistakes at UART HAL-driver. It work for transfer some bytes only. If need bulk transfer (about hundred thousand) both HAL_UART_Transmit_DMA as HAL_UART_Transmit_IT make bugs... I don't khow why. Only HAL_UART_Transmit work correct.
May be I don't understand work with UART HAL-driver.
======== my code start ========================
// after init UART -------------------------start
#define iBufRecSize 2
char rx_buffer[iBufRecSize];
// Define buffer for receive 2 bytes only
huart1.RxXferSize = iBufRecSize;
huart1.pRxBuffPtr = (uint8_t *) & rx_buffer;
// But CallBack must be call after 1 byte
huart1.RxXferCount = 1;
// Enable Interrupt for receive byte
__HAL_UART_ENABLE_IT(& huart1,UART_IT_RXNE);
// after init UART ---------------------------------------end
// CallBack Function -------------------------start
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
// Get One byte
char * point;
point = (char *) UartHandle->pRxBuffPtr;
point --; // After Received Symbol Pointer Move To Next
<Place Where Save Received Byte> = * point;
// Repeat Initialize For Receive One Byte
UartHandle->pRxBuffPtr = (uint8_t *) & rx_buffer;
UartHandle->RxXferCount = 1;
UartHandle->RxXferSize = iBufRecSize;
__HAL_UART_ENABLE_IT(UartHandle,UART_IT_RXNE);
}
// CallBack Function -------------------------end
======== my code end ========================
2018-11-05 02:00 AM
Sorry!
I saw in CubeMX switch "HAL/LL" ;)
Possible some months I went by wrong way !