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.

This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Karl Yamashita
Principal

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

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
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.