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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-15 07:04 AM
HELLO,I resolved the problem and I want to share the solution with you: the issue is with the RX is always pulled down by the BLDC,, just I changed the brushless controller and all is ok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 10:54 AM
Perhaps you're looking at the wrong end of the problem?
Perhaps make the receive here accumulate data and output some kind of diagnostic.
Don't ignore error codes returned, and check the status of the USART and that's it's not holding some sticky failure status, like Noise, Framing, Overrun, or whatever.
Using the debugger, single stepping, and viewing the peripheral registers is unlikely to be a helpful approach.
Add more diagnostic output so you understand what the STM32 is doing / seeing.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 03:03 PM - edited ‎2024-01-10 03:09 PM
You probably didn't enable the NVIC for the UART.
You call HAL_UART_Receive_IT in two different places but 1 of them is set to interrupt on 1 byte instead of 10.
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-10 10:59 PM
yhe nvic was enabled. the uart transmit work well.but the uart recieve don't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 11:31 PM
Hard to tell what you're doing unless you post a more relevant code. You haven't posted any code on readParameter function so don't know how you're checking for received data. Your code doesn't show any transmit either so contradicts you saying that the transmit works..
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-10 11:36 PM - edited ‎2024-01-10 11:40 PM
@Karl Yamashita wrote:Hard to tell what you're doing unless you post a more relevant code. You haven't posted any code on readParameter function so don't know how you're checking for received data. Your code doesn't show any transmit either so contradicts you saying that the transmit works..
i made an entry error .infact. readparameter() is void sendParameter(uint8_t p
arameter) but even ithat still not working
the transmit work well you can see the image below (frame to send) is the same data i have sent with uart transmit .uint8_t senddata[4] = {0x66, 0x42, 0x00, 0xA8};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 11:42 PM
You say the receiver is not operating as expected but give no explanation. How are you checking for received data?
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-10 11:46 PM
the reciver have to revieve a frame ( the image frame to revieve took with logic analyzer) but the uart recieve it () dont fired.. i cheked that with live expression.look at the image(recieve pb)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 11:58 PM
When you call the first HAL_UART_Receive_IT you don't check the HAL status so how do you know if interrupt mode is enabled? Is this a custom 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:06 AM - edited ‎2024-01-11 12:10 AM
No but i made a break point at the first HAL_UART_Recieve _IT , he didtn't even enter the function
I also noticed if I remove the delay HAL_Delay(100); the transmitt will send a missing message
void sendParameter(uint8_t parameter)
{
HAL_UART_Transmit_IT(&huart1, senddata, 4);
HAL_Delay(100);
}
it send this
uint8_t senddata[4] = {0x66, 0x42, 0xA8}; instead this uint8_t senddata[4] = {0x66, 0x42, 0x00, 0xA8};