Uart receiver pb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 10:46 AM
i have established communication with a BLDC (Brushless DC) controller. Initially, i send a message to the controller using the function void sendParameter(uint8_t parameter). Following this transmission, the BLDC controller is expected to respond with a frame. Although the transmission process appears to be functioning correctly, the receiver is not operating as expected. i have confirmed this issue using a logic analyzer.
UART_HandleTypeDef huart1;
uint8_t buffer[10];
uint8_t senddata[4] = {0x66, 0x42, 0x00, 0xA8};
uint8_t transmitAllowed = 1;
-----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void)
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Receive_IT(&huart1, buffer, 1);
}
void sendParameter(uint8_t parameter)
{
HAL_UART_Transmit_IT(&huart1, senddata, 4);
HAL_Delay(100);
}
*/
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
HAL_UART_Receive_IT(&huart1, buffer, 10);
while (1)
{
readParameter(0x42);
}
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 12:13 AM
If it didn't enter the function then the interrupt is not enabled. If it did enter and returns, you'll get return status HAL_OK.
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 12:16 AM
Just upload the whole project so we can see the actual code and the ioc file. And let us know if you're using a custom board or a Nucleo/Discovery board.
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 12:17 AM
i will verify again , thank you for answering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 12:23 AM - edited ‎2024-01-11 12:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 01:19 AM
You've changed the clock settings from the default board setup. I don't have that board so I can't test if those new settings are causing an issue. Just start a new project using the default settings it creates.
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 02:23 AM
@kkhli.1 "yhe nvic was enabled."
That's necessary - but not sufficient.
As well as having the NVIC correctly configured, you also need the UART to be correctly configured to generate interrupts.
"the uart transmit work well. but the uart recieve don't work."
Could mean that you don't have the receive interrupt enabled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 06:27 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 06:42 AM
I thought you said you were abandoning this thread, and moving to your new one?
https://community.st.com/t5/stm32-mcus-products/uart-reciever/m-p/627367/highlight/true#M232225
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 07:57 AM
That's 14 bytes but you're requesting 10 bytes. So even if you did get interrupt to work, you're going to have data out of sync.
Modify the UART1 for loopback mode and transmit to see if you receive, but in polling mode. This is to insure the rx input is not broken.
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-11 08:11 AM
So reading the other posts you've created, your received data could be variable length and you're not sure how to receive the different lengths.
Use HAL_UARTEx_ReceiveToIdle_DMA or HAL_UARTEx_ReceiveToIdle_IT, and for the callback use HAL_UARTEx_RxEventCallback
Look at this project on my github which explains how to receive different lengths.
https://github.com/karlyamashita/Nucleo-G431RB_Three_UART/wiki
If you find my solution useful, please click the Accept as Solution so others see the solution.