cancel
Showing results for 
Search instead for 
Did you mean: 

Uart receiver pb

kkhli.1
Associate III

 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);

 

 

  }

26 REPLIES 26
in polling mode, the receiver works well but remains different from what I expect

polling mode.PNG

You're all over the map. First you post a screenshot that shows your buffer of 10 are all zeros and now you're showing a buffer of 14(?) with data.  

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.

no first is with interruption mode ..there is no data..but now i'm using polling mode

Sorry, i missed that you wrote polling. 

Go back to interrupt mode. See if HAL_UART_ErrorCallback is called. If so, check the error code huart->ErrorCode

Here are the possible error codes

#define HAL_UART_ERROR_NONE 0x00000000U /*!< No error */

#define HAL_UART_ERROR_PE 0x00000001U /*!< Parity error */

#define HAL_UART_ERROR_NE 0x00000002U /*!< Noise error */

#define HAL_UART_ERROR_FE 0x00000004U /*!< Frame error */

#define HAL_UART_ERROR_ORE 0x00000008U /*!< Overrun error */

#define HAL_UART_ERROR_DMA 0x00000010U /*!< DMA transfer error */

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.

I looked with a LOgic to analyze the frame sent by stm32 and received by BLDC: I see that when I reduce the delay to 10 ms, I can receive data but not the exact expected frame

void sendParameter(uint8_t parameter)

{

  HAL_UART_Transmit_IT(&huart1, senddata, 4);

HAL_Delay(100);//reduce the delay to 10 ms, 

}

kkhli1_0-1705064335907.png

 

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

Thanks for sharing - be sure to also share this to your other threads about this problem.