cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bugs at UART HAL driver.

VRyza
Associate II

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

3 REPLIES 3
VRyza
Associate II

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 ========================

VRyza
Associate II

Sorry!

I saw in CubeMX switch "HAL/LL" 😉

Possible some months I went by wrong way !