2024-01-11 06:04 AM - edited 2024-01-11 06:18 AM
I have to recieve a frame from a bldc controller , this frame as follows
START CMD LENGTH BAT CUROLD TSNS STATE USER VOL CUR
0x66 | 0x42 | 0x?? | 1 byte | 1 byte | 2 bytes | 1 byte | 2 bytes | 2 bytes | 2 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)
{
}
2024-01-11 06:19 AM
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.
2024-01-11 06:23 AM
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
2024-01-11 06:35 AM
"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.
2024-01-11 07:04 AM
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
2024-01-11 07:23 AM
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...
2024-01-11 07:27 AM
this is the frame sent by the bldc , using the arduino i can read this :
2024-01-11 07:50 AM - edited 2024-01-11 07:52 AM
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: