Skip to main content
Graduate II
January 11, 2024
Question

Uart reciever

  • January 11, 2024
  • 1 reply
  • 2107 views

I have to recieve a frame from a bldc controller , this frame as follows 

START CMD LENGTH BAT CUROLD TSNS STATE USER VOL CUR

0x660x420x??1 byte1 byte2 bytes1 byte2 bytes2 bytes2 bytes

but i didn't receive anything , the problem with how to manage the lengh of every  values 's frame(byte ,2byte)could you help me please? i'm using nucleo F446RE

uint8_t buffer[14];

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN 0 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Receive_IT(&huart1,buffer, 10);

 

}

int main(void)
{

HAL_Init();


SystemClock_Config();

MX_GPIO_Init();
MX_USART1_UART_Init();
HAL_UART_Receive_IT(&huart1,buffer, 10);

/
while (1)
{
}

 

    This topic has been closed for replies.

    1 reply

    Super User
    January 11, 2024

    Duplicates:

    https://community.st.com/t5/stm32-mcus-products/uart-receiver-pb/td-p/626982

    https://community.st.com/t5/stm32-mcus-products/uart/td-p/626343

     

    Maybe follow through on your previous posts on the topic. You got engagement on these topics from members, then stopped replying and/or didn't answer the questions asked.

    If you just want code, there are examples in the CubeMX repository for handling UART in interrupt mode.

    kkhli.1Author
    Graduate II
    January 11, 2024

    i made many error in the last post that 's why i make a new one  , i get that the problem with the data length , so that is why i 'm asking for help

    Super User
    January 11, 2024

    "i made many error in the last post that 's why i make a new one"

    Well, you could have said that - instead of just abandoning the others.

    Please go back to those other threads, and say that, and link to this thread - so that people don't waste more time in those threads.

    The points from the other thread still stand: are you sure that you have enabled the receive interrupt?

    Before getting bogged-down with interrupts, your protocol, and the BLDC controller, can you receive just one single character from a PC terminal without using interrupts? There's no point adding any extra complications before you've got that basic first step working!

    Once you can receive a character without interrupts, then - and only then - try to receive just one single character from a PC terminal using interrupts.

    As always, take things one simple step at a time - don't try to do everything in one giant leap.