AnsweredAssumed Answered

DMA Interrupt

Question asked by aras.tolga on Apr 26, 2016
Latest reply on Apr 26, 2016 by robitzki.torsten
Hi

I have a problem with the DMA Interrupt on a nucleo stm32f446. Everytime the Nucleo goes into an Infinite_Loop

1.    .section    .text.Default_Handler,"ax",%progbits
2.Default_Handler:
3.Infinite_Loop:
4.    b   Infinite_Loop
5.    .size   Default_Handler, .-Default_Handler


my main.cpp is this one:
01.#include "mbed.h"
02.#include "globals.h"
03.UART_HandleTypeDef huart2;
04.DMA_HandleTypeDef hdma_usart2_tx;
05.void DMA1_Stream6_IRQHandler(void); 
06.void SystemClock_Config(void);
07.static void MX_GPIO_Init(void);
08.static void MX_DMA_Init(void);
09. 
10.void test(DMA_HandleTypeDef* dma){
11.    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,GPIO_PIN_RESET);
12.    char buffer[] ="12345678901234567890123456789000000";
13.    HAL_DMA_Start_IT(&hdma_usart2_tx, (uint32_t) &buffer, (uint32_t)&(USART2->DR),sizeof(buffer));
14.    USART2->CR3 |= USART_CR3_DMAT;
15.}
16. 
17.void HAL_UART_MspInit(UART_HandleTypeDef* huart)
18.{
19. 
20.  GPIO_InitTypeDef GPIO_InitStruct;
21.  if(huart->Instance==USART2)
22.  {
23.  /* USER CODE BEGIN USART2_MspInit 0 */
24. 
25.  /* USER CODE END USART2_MspInit 0 */
26.    /* Peripheral clock enable */
27.    __USART2_CLK_ENABLE();
28. 
29.    /**USART2 GPIO Configuration
30.    PA2     ------> USART2_TX
31.    PA3     ------> USART2_RX
32.    */
33.    GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
34.    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
35.    GPIO_InitStruct.Pull = GPIO_PULLUP;
36.    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
37.    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
38.    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
39. 
40.    /* Peripheral DMA init*/
41.    hdma_usart2_tx.Instance = DMA1_Stream6;
42.    hdma_usart2_tx.Init.Channel = DMA_CHANNEL_4;
43.    hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
44.    hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
45.    hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
46.    hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
47.    hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
48.    hdma_usart2_tx.Init.Mode = DMA_NORMAL;
49.    hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
50.    hdma_usart2_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
51.    hdma_usart2_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
52.    hdma_usart2_tx.Init.MemBurst = DMA_MBURST_SINGLE;
53.    hdma_usart2_tx.Init.PeriphBurst = DMA_PBURST_SINGLE;
54.    hdma_usart2_tx.XferCpltCallback = test;
55.    HAL_DMA_Init(&hdma_usart2_tx);
56. 
57.    __HAL_LINKDMA(huart,hdmatx,hdma_usart2_tx);
58. 
59.  /* USER CODE BEGIN USART2_MspInit 1 */
60. 
61.  /* USER CODE END USART2_MspInit 1 */
62.  }
63. 
64.}
65. 
66.void MX_USART2_UART_Init(void)
67.{
68. 
69.  huart2.Instance = USART2;
70.  huart2.Init.BaudRate = 115200;
71.  huart2.Init.WordLength = UART_WORDLENGTH_8B;
72.  huart2.Init.StopBits = UART_STOPBITS_1;
73.  huart2.Init.Parity = UART_PARITY_NONE;
74.  huart2.Init.Mode = UART_MODE_TX_RX;
75.  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
76.  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
77.  HAL_UART_Init(&huart2);
78.}
79. 
80. 
81.int main() {
82.        /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
83.        HAL_Init();
84. 
85.        /* Initialize all configured peripherals */
86.        MX_GPIO_Init();
87.        HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5, GPIO_PIN_SET);
88.        MX_DMA_Init();
89.        MX_USART2_UART_Init();
90.        char buffer[] ="12345678901234567890123456789000000";
91.        HAL_DMA_Start_IT(&hdma_usart2_tx, (uint32_t) &buffer, (uint32_t) &(USART2->DR),sizeof(buffer));
92.        USART2->CR3 |= USART_CR3_DMAT;
93. 
94.        while(1){}
95.}

void DMA1_Stream6_IRQHandler(void)
{
  /* USER CODE BEGIN DMA1_Stream6_IRQn 0 */
  HAL_NVIC_ClearPendingIRQ(DMA1_Stream6_IRQn);
  /* USER CODE END DMA1_Stream6_IRQn 0 */
  HAL_DMA_IRQHandler(&hdma_usart2_tx);
  /* USER CODE BEGIN DMA1_Stream6_IRQn 1 */


  /* USER CODE END DMA1_Stream6_IRQn 1 */
}

Outcomes