Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: T4 DMA Buffer of data to a pin as serial data.

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    3

    T4 DMA Buffer of data to a pin as serial data.

    I am trying to use DMA on the T4 to output a buffer of data on an pin. Similar to what the WS2812Serial did on the T3. Is there some guidance for this sort of DMA output?

  2. #2
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    I would like to be able to do something like

    uint32_t myBuffer[352];
    //Define the pin we will use for output
    int myPin = 22;
    int Location = 10;
    myDMA = new DMAChannel();
    myDMA.disable();
    myDMA.attachInterrupt(UpdateLocation);
    myDMA.interruptAtCompletion();
    //output 23 bytes of the buffer starting at Location
    myDMA.sourceBuffer((uint8_t *)myBuffer[Location],23);
    //output data serially on myPin
    myDMA.destination(myPin );
    // set 8 cycle wait between output bits
    myDMA.TCD->BWC = 11b;
    myDMA.transferSize(1);
    myDMA.disableOnCompletion();
    myDMA.triggerContinuously();
    myDMA.enable();

    void UpdateLocation(void){
    //logic that updates the location to a different spot in the buffer
    Location += 18;
    myDMA.disable();
    myDMA.sourceBuffer((uint8_t *)myBuffer[Location], 23);
    myDMA.enable();

    }

    void loop() {
    //do some stuff
    if (condition) { myDMA.start(); }
    //do other stuff
    }

  3. #3
    I'm doing something similar here (sorry it's kind of ugly test code): https://forum.pjrc.com/threads/57211...-DMA-to-LPUART

  4. #4
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    I will take a look and see if I can adapt you are doing here to my current problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •