2023-07-05 11:50 PM
Hi,
I'm currently working on sending signals through FDCAN or UART of B-G431B-ESC1 while driving a motor.
I have written a debug code which sends UART data when a button is pressed.
However, the function is called once and never called again, nor the motor won't start.
"stm32g4xx_mc_it"
uint8_t mc_it_debug[64];
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_COMP1_Init();
MX_COMP2_Init();
MX_COMP4_Init();
MX_CORDIC_Init();
MX_DAC3_Init();
MX_OPAMP1_Init();
MX_OPAMP2_Init();
MX_OPAMP3_Init();
MX_TIM1_Init();
MX_MotorControl_Init();
MX_FDCAN1_Init();
MX_USART2_UART_Init();
/* Initialize interrupts */
MX_NVIC_Init();
I am assuming it is a priority issue, which is set as
Any advice will be helpful.
Solved! Go to Solution.
2023-07-16 08:51 PM - edited 2023-07-16 08:51 PM
In the software side, it works fine, but when I try to debug using oscilloscope, the waveform won't show.
In TSK_HighFrequencyTask() (16 kHz), I downsampled to 8kHz, then stores alphabeta current and voltage (8 bytes per cycle) to a 64 byte buffer then sends a FDCAN signal storing that buffer. (so tx frequency is 1kHz)
my code :
// in fdcan.c,
// in mc_tasks.c, TSK_HighFrequencyTask()
/* USER CODE BEGIN HighFrequencyTask 1 */
(void)TSK_StoreToBuffer(TxData, buffer_index);
/* USER CODE END HighFrequencyTask 1 */
Any thoughts on what am I missing?
2023-07-17 04:00 AM
Sorry, it was a programming issue.
2023-07-17 04:10 AM
Okay...
Did the debouncing do the trick for the first basic problem?
2023-07-17 06:36 PM
I couldn't due to my lack of programming skills. I will keep in mind when I start another project using UART.
2023-07-19 04:14 PM
So why the wrong answer was selected as a solution?
2023-07-19 05:12 PM
Sorry, got mixed up with my main goal (FDCAN + motorcontrol) with this topic (UART_DMA + GPIO interrupt(button))
I didn't mention that at first I sent FDCAN messages when button is pressed, then the FDCAN RX interrupt will send UART_DMA message. Which didn't work (also motorcontrol stopped operating), so I decided to send UART DMA message directly when button is pressed, which is the question stated here.
So can you edit this topic as not solved?
2023-07-19 05:29 PM - edited 2023-07-19 05:33 PM
Sounds like issues of interrupt safety, priorities, the ST's broken bloatware etc.
The menu on the right side of the particular solution post has an option "Not the Solution".
2023-07-19 05:31 PM
thanks