cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in UART INTERRUPT call back function

Ravi_shankar
Visitor

Hey guys!

I am currently working on stm32F2 series, the issue i was facing in   HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) when the UART transmit the first byte the interrupt call back function is not called instead calling the RxCpltCallback it call the " USART1_IRQHandler(void) "and the  RxCpltCallback function does not trigger at first byte in UART at the second byte it call the  RxCpltCallback  function and it works fine and i attached the code i was wrote 

#include "main.h"

UART_HandleTypeDef huart1;
UART_HandleTypeDef huart3;

unsigned char ra_buffer[32];

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART3_UART_Init(void);

int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_USART3_UART_Init();

HAL_UART_Receive_IT(&huart1,ra_buffer,12);

while (1)
{

HAL_Delay(1000);

}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{

HAL_UART_Receive_IT(&huart1,ra_buffer,1);
HAL_UART_Transmit(&huart3,ra_buffer, 1,100);

}

1 REPLY 1
KnarfB
Super User

> HAL_UART_Receive_IT(&huart1,ra_buffer,12);

will call HAL_UART_RxCpltCallback only after 12 bytes received.

USART1_IRQHandler is called internally after each byte until the limit you have set (here: 12) ist reached.