cancel
Showing results for 
Search instead for 
Did you mean: 

Uart reciever

kkhli.1
Associate III

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)
{
}

 

7 REPLIES 7
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".
kkhli.1
Associate III

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

"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.

first i tryed to transmit a data with arduino to stm32 , so i  received the all data ,what i did i sent with arduino a  buffer[5]={0X66,0x22, 0X44 OX56 0x 33}  so with stm32 i received this data , the problem is with bldc  is working with an arduino using srial. read()  but with stm32 i can't recieve anything

Are you sure that all connections are correct with the BLDC - including a good ground reference?

Are voltage levels correct?

I think you said in one of your other threads that you have a logic analyser?

So use that to see what is the difference between what the Arduino sends, and what your BLDC sends...

this is the frame sent by the bldc , using the arduino i can read this :frame to receive.PNG

You said you could send successfully from Arduino to STM32.

So look at what the Arduino sends, and compare that to what the BLDC sends.

As mentioned in one of your other threads, check if the UART is giving any error(s) with what the BLDC sends - eg, framing errors...

And, again: 

  • Are you sure that all connections are correct with the BLDC - including a good ground reference?
  • Are voltage levels correct?