cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling B-G431-ESC1 brushless motor controller via a master microcontroller (ATmega2560) over UART. Can't find resources.

Popeye
Associate III

Hi, I'm trying to control a BLDC motor via a B-G431B-ESC1 and an Arduino Mega. The Mega will be the master and send commands to the board. For ease of use, I'd like if it these were strings. I have found examples of how to use UART in an STM32 application, except here the DMA UART initialization is done by ST MotorControl and ST MX, so I don't know if there are implications. The initialization has all of the below in it, so it seems DMA is disabled.

 MX_USART2_UART_Init();
...
  sConfig.DAC_DMADoubleDataMode = DISABLE;
...
  hadc1.Init.DMAContinuousRequests = DISABLE;
...
  hadc2.Init.DMAContinuousRequests = DISABLE;

Furthermore, I don't see an interrupt being declared anywhere for UART, there's just this:

  /* Initialize interrupts */
  MX_NVIC_Init();
  /* USER CODE BEGIN 2 */

Very frustrating. Would greatly appreciate some help, I feel like this is something that is done in 10 lines of code.

Thank you in advance, kind soul.

2 REPLIES 2
Karl Yamashita
Lead III

If the strings are variable length then you're better off with UART DMA with idle bit using HAL_UARTEx_ReceiveToIdle_DMA and HAL_UARTEx_RxEventCallback

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
Popeye
Associate III

In a generic application, I'm sure this would work, but I'm dubious about writing over code generated by ST MotorControl. I guess I won't know if I don't try.