I am trying to use DMA for reading the data from MCU in mbed, therefore I had to use HAL layer as mbed doesn’t support DMA. The problem is I DMA interrupt isn’t triggered although I am doing exact Init routine as CubeMx generated code does. I have checked couple of times and it’s same, does anybody have or had the similar problem to help me with it?
Yes I am using extern “C” linkage but still MCU stops working when it should be handling interrupt, I also tried simple GPIO IT using HAL to check what was the problem. Maybe I am missing something, here is the source for second one though, maybe you can help with it.
#include "mbed.h"
#include "TraceVSPI.h"
#define debug_printf TraceVSPI::printf
extern "C" void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
/*Configure GPIO pin : PE3 */
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pin : PE10 */
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/* EXTI interrupt init*/
//NVIC_SetVector(EXTI15_10_IRQn, (uint32_t) HAL_GPIO_EXTI_IRQHandler);
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
}
extern "C" void EXTI15_10_IRQHandler(void)
{
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
debug_printf("!");
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_10);
/* USER CODE END EXTI15_10_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
/* USER CODE END EXTI15_10_IRQn 1 */
}
extern "C" void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
int main()
{
HAL_Init();
MX_GPIO_Init();
TraceVSPI::init();
debug_printf("Trace Init Done -- \r\n");
ThisThread::sleep_for(500ms);
debug_printf("Relay Init -- \r\n");
while (1){
debug_printf("time pass -- \r\n");
ThisThread::sleep_for(500ms);
}
}
removed debug_printf(“!”); and everything works just fine, as it turns out my function was taking too much time and interfering with interrupt handler.