Using DMA controller to transmit UART





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have been trying exhaustively to program my STM32F7xx microcontroller to use DMA to transmit to UART. Three things are going on and I cannot explain or understand why this is happening, and hope somebody can help me out with this issue.




  1. In the main while loop, I am printing three interrupt status flags. These flags are set if the corresponding ISR has been called. I added this to check if the ISR was called without adding blocking statements in the ISRs. None of the interrupts, however, are called.

  2. The DMA only transmits 1 sequence of 513 bytes. When I modify the while loop in my main to only contain HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);, nothing changes, the function is only called/executed once.

  3. In the while loop, I print the status of the ISR flags. After printing, the CPU stops/locks/shutdown/exits the while loop. At first, I thought I was congesting the AHB by using the UART to my terminal and the UART for the DMA controller. I disabled my terminal, and used LEDs, this didn't change anything.


Currently, the only running hypothesis I have is that my CPU somehow has interrupts disabled.



#include "stm32f7xx.h"
#include "mbed.h"

uint8_t dmxBuffer[513];
volatile bool irqA = false;
volatile bool irqB = false;
volatile bool irqC = false;

Serial pc(USBTX, USBRX, 115200);

UART_HandleTypeDef handleUart4;
DMA_HandleTypeDef handleDma;

void initialiseGPIO()
{
GPIO_InitTypeDef GPIO_InitStruct;

__GPIOA_CLK_ENABLE();

/**UART4 GPIO Configuration
PA0 ------> USART4_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}

void initialiseDMAController()
{
/* DMA controller clock enable */
__DMA1_CLK_ENABLE();

/* Peripheral DMA init*/
handleDma.Instance = DMA1_Stream4;
handleDma.Init.Channel = DMA_CHANNEL_4;
handleDma.Init.Direction = DMA_MEMORY_TO_PERIPH;
handleDma.Init.PeriphInc = DMA_PINC_DISABLE;
handleDma.Init.MemInc = DMA_MINC_ENABLE;
handleDma.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
handleDma.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
handleDma.Init.Mode = DMA_NORMAL;
handleDma.Init.Priority = DMA_PRIORITY_MEDIUM;
handleDma.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
HAL_DMA_Init(&handleDma);

//Define
__HAL_LINKDMA(&handleUart4,hdmatx,handleDma);

/* DMA interrupt init */
HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
}

void initialiseUart()
{
__UART4_CLK_ENABLE();

handleUart4.Instance = UART4;
handleUart4.Init.BaudRate = 250000;
handleUart4.Init.WordLength = UART_WORDLENGTH_8B;
handleUart4.Init.StopBits = UART_STOPBITS_2;
handleUart4.Init.Parity = UART_PARITY_NONE;
handleUart4.Init.Mode = UART_MODE_TX;
handleUart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
handleUart4.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&handleUart4);

/* Peripheral interrupt init*/
HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);
}

/* This function handles DMA1 stream4 global interrupt. */
void DMA1_Stream4_IRQHandler(void)
{
irqA = true;
HAL_DMA_IRQHandler(&handleDma);
}

/* This function handles the UART4 interups */
void UART4_IRQHandler(void)
{
irqB = true;
HAL_UART_IRQHandler(&handleUart4);
}

//HAL_UART_TxCpltCallback
/* This callback function is called when the DMA successfully transmits all scheduled bytes. */
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
irqC = true;
}


int main(void)
{
/* Reset of all peripherals */
HAL_Init();

//Initialise peripherals
initialiseGPIO();
initialiseDMAController();
initialiseUart();

//Fill buffer with test data
for (int x = 0; x < 100; x++)
{
dmxBuffer[x] = x;
}

//Now instruct the UART peripheral to transmit 513 bytes using the DMA controller.
HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);

while(1)
{
pc.printf("irqA: %d - irqB: %d - irqC: %drn", irqA, irqB, irqC);
wait_ms(100); //Wait to see if any of the interupt handlers / callback functions are called

//Check if all bytes are sent, if so, retransmit
if (irqC)
{
irqC = false;
HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);
}

}
}









share|improve this question





























    0















    I have been trying exhaustively to program my STM32F7xx microcontroller to use DMA to transmit to UART. Three things are going on and I cannot explain or understand why this is happening, and hope somebody can help me out with this issue.




    1. In the main while loop, I am printing three interrupt status flags. These flags are set if the corresponding ISR has been called. I added this to check if the ISR was called without adding blocking statements in the ISRs. None of the interrupts, however, are called.

    2. The DMA only transmits 1 sequence of 513 bytes. When I modify the while loop in my main to only contain HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);, nothing changes, the function is only called/executed once.

    3. In the while loop, I print the status of the ISR flags. After printing, the CPU stops/locks/shutdown/exits the while loop. At first, I thought I was congesting the AHB by using the UART to my terminal and the UART for the DMA controller. I disabled my terminal, and used LEDs, this didn't change anything.


    Currently, the only running hypothesis I have is that my CPU somehow has interrupts disabled.



    #include "stm32f7xx.h"
    #include "mbed.h"

    uint8_t dmxBuffer[513];
    volatile bool irqA = false;
    volatile bool irqB = false;
    volatile bool irqC = false;

    Serial pc(USBTX, USBRX, 115200);

    UART_HandleTypeDef handleUart4;
    DMA_HandleTypeDef handleDma;

    void initialiseGPIO()
    {
    GPIO_InitTypeDef GPIO_InitStruct;

    __GPIOA_CLK_ENABLE();

    /**UART4 GPIO Configuration
    PA0 ------> USART4_TX
    */
    GPIO_InitStruct.Pin = GPIO_PIN_0;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    }

    void initialiseDMAController()
    {
    /* DMA controller clock enable */
    __DMA1_CLK_ENABLE();

    /* Peripheral DMA init*/
    handleDma.Instance = DMA1_Stream4;
    handleDma.Init.Channel = DMA_CHANNEL_4;
    handleDma.Init.Direction = DMA_MEMORY_TO_PERIPH;
    handleDma.Init.PeriphInc = DMA_PINC_DISABLE;
    handleDma.Init.MemInc = DMA_MINC_ENABLE;
    handleDma.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
    handleDma.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    handleDma.Init.Mode = DMA_NORMAL;
    handleDma.Init.Priority = DMA_PRIORITY_MEDIUM;
    handleDma.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
    HAL_DMA_Init(&handleDma);

    //Define
    __HAL_LINKDMA(&handleUart4,hdmatx,handleDma);

    /* DMA interrupt init */
    HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
    }

    void initialiseUart()
    {
    __UART4_CLK_ENABLE();

    handleUart4.Instance = UART4;
    handleUart4.Init.BaudRate = 250000;
    handleUart4.Init.WordLength = UART_WORDLENGTH_8B;
    handleUart4.Init.StopBits = UART_STOPBITS_2;
    handleUart4.Init.Parity = UART_PARITY_NONE;
    handleUart4.Init.Mode = UART_MODE_TX;
    handleUart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    handleUart4.Init.OverSampling = UART_OVERSAMPLING_16;
    HAL_UART_Init(&handleUart4);

    /* Peripheral interrupt init*/
    HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(UART4_IRQn);
    }

    /* This function handles DMA1 stream4 global interrupt. */
    void DMA1_Stream4_IRQHandler(void)
    {
    irqA = true;
    HAL_DMA_IRQHandler(&handleDma);
    }

    /* This function handles the UART4 interups */
    void UART4_IRQHandler(void)
    {
    irqB = true;
    HAL_UART_IRQHandler(&handleUart4);
    }

    //HAL_UART_TxCpltCallback
    /* This callback function is called when the DMA successfully transmits all scheduled bytes. */
    void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
    {
    irqC = true;
    }


    int main(void)
    {
    /* Reset of all peripherals */
    HAL_Init();

    //Initialise peripherals
    initialiseGPIO();
    initialiseDMAController();
    initialiseUart();

    //Fill buffer with test data
    for (int x = 0; x < 100; x++)
    {
    dmxBuffer[x] = x;
    }

    //Now instruct the UART peripheral to transmit 513 bytes using the DMA controller.
    HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);

    while(1)
    {
    pc.printf("irqA: %d - irqB: %d - irqC: %drn", irqA, irqB, irqC);
    wait_ms(100); //Wait to see if any of the interupt handlers / callback functions are called

    //Check if all bytes are sent, if so, retransmit
    if (irqC)
    {
    irqC = false;
    HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);
    }

    }
    }









    share|improve this question

























      0












      0








      0








      I have been trying exhaustively to program my STM32F7xx microcontroller to use DMA to transmit to UART. Three things are going on and I cannot explain or understand why this is happening, and hope somebody can help me out with this issue.




      1. In the main while loop, I am printing three interrupt status flags. These flags are set if the corresponding ISR has been called. I added this to check if the ISR was called without adding blocking statements in the ISRs. None of the interrupts, however, are called.

      2. The DMA only transmits 1 sequence of 513 bytes. When I modify the while loop in my main to only contain HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);, nothing changes, the function is only called/executed once.

      3. In the while loop, I print the status of the ISR flags. After printing, the CPU stops/locks/shutdown/exits the while loop. At first, I thought I was congesting the AHB by using the UART to my terminal and the UART for the DMA controller. I disabled my terminal, and used LEDs, this didn't change anything.


      Currently, the only running hypothesis I have is that my CPU somehow has interrupts disabled.



      #include "stm32f7xx.h"
      #include "mbed.h"

      uint8_t dmxBuffer[513];
      volatile bool irqA = false;
      volatile bool irqB = false;
      volatile bool irqC = false;

      Serial pc(USBTX, USBRX, 115200);

      UART_HandleTypeDef handleUart4;
      DMA_HandleTypeDef handleDma;

      void initialiseGPIO()
      {
      GPIO_InitTypeDef GPIO_InitStruct;

      __GPIOA_CLK_ENABLE();

      /**UART4 GPIO Configuration
      PA0 ------> USART4_TX
      */
      GPIO_InitStruct.Pin = GPIO_PIN_0;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_PULLUP;
      GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
      }

      void initialiseDMAController()
      {
      /* DMA controller clock enable */
      __DMA1_CLK_ENABLE();

      /* Peripheral DMA init*/
      handleDma.Instance = DMA1_Stream4;
      handleDma.Init.Channel = DMA_CHANNEL_4;
      handleDma.Init.Direction = DMA_MEMORY_TO_PERIPH;
      handleDma.Init.PeriphInc = DMA_PINC_DISABLE;
      handleDma.Init.MemInc = DMA_MINC_ENABLE;
      handleDma.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
      handleDma.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
      handleDma.Init.Mode = DMA_NORMAL;
      handleDma.Init.Priority = DMA_PRIORITY_MEDIUM;
      handleDma.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
      HAL_DMA_Init(&handleDma);

      //Define
      __HAL_LINKDMA(&handleUart4,hdmatx,handleDma);

      /* DMA interrupt init */
      HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
      HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
      }

      void initialiseUart()
      {
      __UART4_CLK_ENABLE();

      handleUart4.Instance = UART4;
      handleUart4.Init.BaudRate = 250000;
      handleUart4.Init.WordLength = UART_WORDLENGTH_8B;
      handleUart4.Init.StopBits = UART_STOPBITS_2;
      handleUart4.Init.Parity = UART_PARITY_NONE;
      handleUart4.Init.Mode = UART_MODE_TX;
      handleUart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
      handleUart4.Init.OverSampling = UART_OVERSAMPLING_16;
      HAL_UART_Init(&handleUart4);

      /* Peripheral interrupt init*/
      HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
      HAL_NVIC_EnableIRQ(UART4_IRQn);
      }

      /* This function handles DMA1 stream4 global interrupt. */
      void DMA1_Stream4_IRQHandler(void)
      {
      irqA = true;
      HAL_DMA_IRQHandler(&handleDma);
      }

      /* This function handles the UART4 interups */
      void UART4_IRQHandler(void)
      {
      irqB = true;
      HAL_UART_IRQHandler(&handleUart4);
      }

      //HAL_UART_TxCpltCallback
      /* This callback function is called when the DMA successfully transmits all scheduled bytes. */
      void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
      {
      irqC = true;
      }


      int main(void)
      {
      /* Reset of all peripherals */
      HAL_Init();

      //Initialise peripherals
      initialiseGPIO();
      initialiseDMAController();
      initialiseUart();

      //Fill buffer with test data
      for (int x = 0; x < 100; x++)
      {
      dmxBuffer[x] = x;
      }

      //Now instruct the UART peripheral to transmit 513 bytes using the DMA controller.
      HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);

      while(1)
      {
      pc.printf("irqA: %d - irqB: %d - irqC: %drn", irqA, irqB, irqC);
      wait_ms(100); //Wait to see if any of the interupt handlers / callback functions are called

      //Check if all bytes are sent, if so, retransmit
      if (irqC)
      {
      irqC = false;
      HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);
      }

      }
      }









      share|improve this question














      I have been trying exhaustively to program my STM32F7xx microcontroller to use DMA to transmit to UART. Three things are going on and I cannot explain or understand why this is happening, and hope somebody can help me out with this issue.




      1. In the main while loop, I am printing three interrupt status flags. These flags are set if the corresponding ISR has been called. I added this to check if the ISR was called without adding blocking statements in the ISRs. None of the interrupts, however, are called.

      2. The DMA only transmits 1 sequence of 513 bytes. When I modify the while loop in my main to only contain HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);, nothing changes, the function is only called/executed once.

      3. In the while loop, I print the status of the ISR flags. After printing, the CPU stops/locks/shutdown/exits the while loop. At first, I thought I was congesting the AHB by using the UART to my terminal and the UART for the DMA controller. I disabled my terminal, and used LEDs, this didn't change anything.


      Currently, the only running hypothesis I have is that my CPU somehow has interrupts disabled.



      #include "stm32f7xx.h"
      #include "mbed.h"

      uint8_t dmxBuffer[513];
      volatile bool irqA = false;
      volatile bool irqB = false;
      volatile bool irqC = false;

      Serial pc(USBTX, USBRX, 115200);

      UART_HandleTypeDef handleUart4;
      DMA_HandleTypeDef handleDma;

      void initialiseGPIO()
      {
      GPIO_InitTypeDef GPIO_InitStruct;

      __GPIOA_CLK_ENABLE();

      /**UART4 GPIO Configuration
      PA0 ------> USART4_TX
      */
      GPIO_InitStruct.Pin = GPIO_PIN_0;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_PULLUP;
      GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
      }

      void initialiseDMAController()
      {
      /* DMA controller clock enable */
      __DMA1_CLK_ENABLE();

      /* Peripheral DMA init*/
      handleDma.Instance = DMA1_Stream4;
      handleDma.Init.Channel = DMA_CHANNEL_4;
      handleDma.Init.Direction = DMA_MEMORY_TO_PERIPH;
      handleDma.Init.PeriphInc = DMA_PINC_DISABLE;
      handleDma.Init.MemInc = DMA_MINC_ENABLE;
      handleDma.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE;
      handleDma.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
      handleDma.Init.Mode = DMA_NORMAL;
      handleDma.Init.Priority = DMA_PRIORITY_MEDIUM;
      handleDma.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
      HAL_DMA_Init(&handleDma);

      //Define
      __HAL_LINKDMA(&handleUart4,hdmatx,handleDma);

      /* DMA interrupt init */
      HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
      HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
      }

      void initialiseUart()
      {
      __UART4_CLK_ENABLE();

      handleUart4.Instance = UART4;
      handleUart4.Init.BaudRate = 250000;
      handleUart4.Init.WordLength = UART_WORDLENGTH_8B;
      handleUart4.Init.StopBits = UART_STOPBITS_2;
      handleUart4.Init.Parity = UART_PARITY_NONE;
      handleUart4.Init.Mode = UART_MODE_TX;
      handleUart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
      handleUart4.Init.OverSampling = UART_OVERSAMPLING_16;
      HAL_UART_Init(&handleUart4);

      /* Peripheral interrupt init*/
      HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
      HAL_NVIC_EnableIRQ(UART4_IRQn);
      }

      /* This function handles DMA1 stream4 global interrupt. */
      void DMA1_Stream4_IRQHandler(void)
      {
      irqA = true;
      HAL_DMA_IRQHandler(&handleDma);
      }

      /* This function handles the UART4 interups */
      void UART4_IRQHandler(void)
      {
      irqB = true;
      HAL_UART_IRQHandler(&handleUart4);
      }

      //HAL_UART_TxCpltCallback
      /* This callback function is called when the DMA successfully transmits all scheduled bytes. */
      void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
      {
      irqC = true;
      }


      int main(void)
      {
      /* Reset of all peripherals */
      HAL_Init();

      //Initialise peripherals
      initialiseGPIO();
      initialiseDMAController();
      initialiseUart();

      //Fill buffer with test data
      for (int x = 0; x < 100; x++)
      {
      dmxBuffer[x] = x;
      }

      //Now instruct the UART peripheral to transmit 513 bytes using the DMA controller.
      HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);

      while(1)
      {
      pc.printf("irqA: %d - irqB: %d - irqC: %drn", irqA, irqB, irqC);
      wait_ms(100); //Wait to see if any of the interupt handlers / callback functions are called

      //Check if all bytes are sent, if so, retransmit
      if (irqC)
      {
      irqC = false;
      HAL_UART_Transmit_DMA(&handleUart4, dmxBuffer, 513);
      }

      }
      }






      arm stm32 uart gpio dma






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 20:46









      Alex van RijsAlex van Rijs

      31341133




      31341133
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Check the interrupt vector table



          Verify that the vector table does indeed contain a pointer to your handler function, not to some generic placeholder with an infinite loop (that makes the program hang).



          Search for the name of the interrupt handler function in the entire source code. Is there any other object or #define that could interfere with the function definition, or the vector table entry?



          Change the name of the handler, both the function definition and the vector table entry. Does it still compile? When not, does adding extern "C" to the function prototype help?



          Look up the address of the handler in the .map file, and the offset entry for the interrupt in the vector table provided in the Reference Manual (Nested vectored interrupt controller (NVIC) / Interrupt and exception vectors). Check the contents of the compiled program binary file at the given offset. Does it match the address found in the .map file + 1?



          Check the value at NVIC->VTOR plus the offset while running the program. It should be the same as the one found in the binary. If not, see that the VTOR register is set to the beginning of the right vector table.






          share|improve this answer
























          • According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

            – Alex van Rijs
            Nov 26 '18 at 8:40











          • @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

            – berendi
            Nov 26 '18 at 9:05













          • @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

            – berendi
            Nov 26 '18 at 9:14












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452768%2fusing-dma-controller-to-transmit-uart%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Check the interrupt vector table



          Verify that the vector table does indeed contain a pointer to your handler function, not to some generic placeholder with an infinite loop (that makes the program hang).



          Search for the name of the interrupt handler function in the entire source code. Is there any other object or #define that could interfere with the function definition, or the vector table entry?



          Change the name of the handler, both the function definition and the vector table entry. Does it still compile? When not, does adding extern "C" to the function prototype help?



          Look up the address of the handler in the .map file, and the offset entry for the interrupt in the vector table provided in the Reference Manual (Nested vectored interrupt controller (NVIC) / Interrupt and exception vectors). Check the contents of the compiled program binary file at the given offset. Does it match the address found in the .map file + 1?



          Check the value at NVIC->VTOR plus the offset while running the program. It should be the same as the one found in the binary. If not, see that the VTOR register is set to the beginning of the right vector table.






          share|improve this answer
























          • According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

            – Alex van Rijs
            Nov 26 '18 at 8:40











          • @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

            – berendi
            Nov 26 '18 at 9:05













          • @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

            – berendi
            Nov 26 '18 at 9:14
















          0














          Check the interrupt vector table



          Verify that the vector table does indeed contain a pointer to your handler function, not to some generic placeholder with an infinite loop (that makes the program hang).



          Search for the name of the interrupt handler function in the entire source code. Is there any other object or #define that could interfere with the function definition, or the vector table entry?



          Change the name of the handler, both the function definition and the vector table entry. Does it still compile? When not, does adding extern "C" to the function prototype help?



          Look up the address of the handler in the .map file, and the offset entry for the interrupt in the vector table provided in the Reference Manual (Nested vectored interrupt controller (NVIC) / Interrupt and exception vectors). Check the contents of the compiled program binary file at the given offset. Does it match the address found in the .map file + 1?



          Check the value at NVIC->VTOR plus the offset while running the program. It should be the same as the one found in the binary. If not, see that the VTOR register is set to the beginning of the right vector table.






          share|improve this answer
























          • According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

            – Alex van Rijs
            Nov 26 '18 at 8:40











          • @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

            – berendi
            Nov 26 '18 at 9:05













          • @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

            – berendi
            Nov 26 '18 at 9:14














          0












          0








          0







          Check the interrupt vector table



          Verify that the vector table does indeed contain a pointer to your handler function, not to some generic placeholder with an infinite loop (that makes the program hang).



          Search for the name of the interrupt handler function in the entire source code. Is there any other object or #define that could interfere with the function definition, or the vector table entry?



          Change the name of the handler, both the function definition and the vector table entry. Does it still compile? When not, does adding extern "C" to the function prototype help?



          Look up the address of the handler in the .map file, and the offset entry for the interrupt in the vector table provided in the Reference Manual (Nested vectored interrupt controller (NVIC) / Interrupt and exception vectors). Check the contents of the compiled program binary file at the given offset. Does it match the address found in the .map file + 1?



          Check the value at NVIC->VTOR plus the offset while running the program. It should be the same as the one found in the binary. If not, see that the VTOR register is set to the beginning of the right vector table.






          share|improve this answer













          Check the interrupt vector table



          Verify that the vector table does indeed contain a pointer to your handler function, not to some generic placeholder with an infinite loop (that makes the program hang).



          Search for the name of the interrupt handler function in the entire source code. Is there any other object or #define that could interfere with the function definition, or the vector table entry?



          Change the name of the handler, both the function definition and the vector table entry. Does it still compile? When not, does adding extern "C" to the function prototype help?



          Look up the address of the handler in the .map file, and the offset entry for the interrupt in the vector table provided in the Reference Manual (Nested vectored interrupt controller (NVIC) / Interrupt and exception vectors). Check the contents of the compiled program binary file at the given offset. Does it match the address found in the .map file + 1?



          Check the value at NVIC->VTOR plus the offset while running the program. It should be the same as the one found in the binary. If not, see that the VTOR register is set to the beginning of the right vector table.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 9:39









          berendiberendi

          4,3631828




          4,3631828













          • According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

            – Alex van Rijs
            Nov 26 '18 at 8:40











          • @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

            – berendi
            Nov 26 '18 at 9:05













          • @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

            – berendi
            Nov 26 '18 at 9:14



















          • According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

            – Alex van Rijs
            Nov 26 '18 at 8:40











          • @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

            – berendi
            Nov 26 '18 at 9:05













          • @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

            – berendi
            Nov 26 '18 at 9:14

















          According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

          – Alex van Rijs
          Nov 26 '18 at 8:40





          According to STM32F7's reference manual, the DMA1Stream4 global interrupt is at memory location: 0x0000007C. This register contains a pointer to the function that should be called. I currently am using an online compiler - mbed - which only generates a bin file for me that I use to program the microcontroller. How can I verify if my interrupt handler function is indeed at the corresponding address?

          – Alex van Rijs
          Nov 26 '18 at 8:40













          @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

          – berendi
          Nov 26 '18 at 9:05







          @AlexvanRijs printf("function address 0x%08lx vector table entry 0x%08lxn", (uint32_t)DMA1_Stream4_IRQHandler, *(uint32_t *)(NVIC->VTOR + 0x7c));

          – berendi
          Nov 26 '18 at 9:05















          @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

          – berendi
          Nov 26 '18 at 9:14





          @AlexvanRijs And find a way to use a proper toolchain with debugger. In the time it takes to figure out simple mistakes using random printf statements, it would be possible to set up an IDE, import the project from mbed, and hit the pause button when it hangs. Twice.

          – berendi
          Nov 26 '18 at 9:14




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452768%2fusing-dma-controller-to-transmit-uart%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?