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

Thread: Teensy 4.0 UART RX to DMA

  1. #1
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10

    Teensy 4.0 UART RX to DMA

    Teensy 4.0 UART RX to DMA

    Can anyone help to convert the T3.6 example below to T4.0?

    Best Regards,
    HuHu

    Code:
    //---------------------------------------------------------------------------------------
    
    //  UART Rx to DMA ping pong
    #include <DMAChannel.h>
    #define PRREG(x) Serial.print(#x" 0x"); Serial.println(x,HEX)
    #define SAMPLES 1024
    
    DMAMEM static uint8_t rx_buffer[SAMPLES];
    DMAChannel dma(false);
    
    volatile uint8_t *dest;
    
    void isr(void)
    {
      uint32_t daddr;
    
      dma.clearInterrupt();
      daddr = (uint32_t)(dma.TCD->DADDR);
    
      if (daddr < (uint32_t)rx_buffer + sizeof(rx_buffer) / 2) {
        // DMA is filling the first half of the buffer
        // so we must print the second half
        dest = &rx_buffer[SAMPLES / 2];
      } else {
        // DMA is filling the second half of the buffer
        // so we must print the first half
        dest = rx_buffer;
      }
    }
    
    void dmainit()
    {
      // set up a DMA channel to store UART byte
      // Serial4  UART3
      dma.begin(true); // Allocate the DMA channel first
    
      dma.source((uint8_t &) UART3_D);
      dma.destinationBuffer(rx_buffer, sizeof(rx_buffer));
    
      dma.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
      dma.triggerAtHardwareEvent(DMAMUX_SOURCE_UART3_RX);
      dma.enable();
      dma.attachInterrupt(isr);
    }
    
    void setup()
    {
      Serial.begin(9600);
      while (!Serial);
      dmainit();
      Serial4.begin(4800);
      UART3_C5 =  UART_C5_RDMAS;  // ? enable DMA
    }
    
    void loop()
    {
      static uint32_t prev = millis();
    
      if (dest) {
        // print or write to SD
        uint32_t t = millis();
        Serial.print(t - prev); Serial.println(" ms");
        Serial.println((uint32_t)dest, HEX);
        for (int i = 0; i < SAMPLES / 2; i++)Serial.print((char)dest[i]);
        Serial.println();
        prev = t;    // interrupt period
        dest = 0;   // wait for next interrupt
      }
    }
    //---------------------------------------------------------------------------------------
    Last edited by KurtE; 11-18-2019 at 03:46 PM. Reason: code tag

  2. #2
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10

    @ PaulStoffregen

    Hi Paul,

    I hope you can help or give some hints.

    Best Regards,

    HuHu

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Sorry I am not Paul...

    Hints? Not sure, I have not done DMA to UARTS before, have done it for SPI, probably similar...

    One hint is to look at SPI library and you can see version that works for T3.x and version that works for T4.

    Looks like on T4 Serial3 is on Uart4. You probably want to look at section 48.4.1 of the IMXRT1060RM PDF to look at Uart register definitions...
    So things like the data register: dma.source((uint8_t &) UART3_D); would probably go to: LPUART4_DATA

    The Dma sources and like probably go to:
    #define DMAMUX_SOURCE_LPUART4_RX 68
    #define DMAMUX_SOURCE_LPUART4_TX 69


    What UART registers you may need to monitor and the like?
    Would take some experimentation, like look at the
    LPUART4_BAUD register, there are fields like: TDMAE, RDMAE, RIDMAE

    There are probably other registers to muck with as well, like: LPUART4_WATER
    which sets up counters and watermark values...

    And maybe some others...

  4. #4
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10
    Quote Originally Posted by KurtE View Post
    Sorry I am not Paul........ And maybe some others...
    Thx KurtE! It doesn't matter that you are not Paul

    I'll give it a try - lots of reading to do - hope i can report my results shortly.

  5. #5
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10
    ..... did some reading but no success!

    Seems that "dmaRXisr" isn't entered

    Serial Monitor output:

    LPUART1_CTRL=0x0
    LPUART1_BAUD=0xF000004


    Code:
    //===============================
    //  UART Rx to DMA (ping<-->pong)
    //===============================
    
    #include <DMAChannel.h>
    DMAChannel dmaRX(false);
    #define SAMPLES 512
    DMAMEM static uint8_t rx_buffer[SAMPLES];
    volatile uint8_t *dest;
    
    void dmaRXinit()
    {
      dmaRX.begin(true); // Allocate the DMA channel
      dmaRX.source((uint8_t &) LPUART1_DATA); // SERIAL2 = LPUART1
      dmaRX.triggerAtHardwareEvent(DMAMUX_SOURCE_LPUART1_RX);
      dmaRX.destinationBuffer(rx_buffer, sizeof(rx_buffer));
      dmaRX.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
      dmaRX.enable();
      dmaRX.attachInterrupt(dmaRXisr);
    }
    
    void dmaRXisr(void)
    {
      uint32_t daddr;  
    
      dmaRX.clearInterrupt();  
      daddr = (uint32_t)(dmaRX.TCD->DADDR);
       
      if (daddr < (uint32_t)rx_buffer + sizeof(rx_buffer) / 2)  
        dest = &rx_buffer[SAMPLES / 2]; 
      else 
        dest = rx_buffer;               
    }
    
    void setup()
    {
      Serial.begin(115200);
      Serial2.begin(9600);
      dmaRXinit();  
      LPUART1_CTRL |= (                
                       LPUART_CTRL_RE |
                       LPUART_CTRL_RIE |               
                       LPUART_CTRL_TCIE |
                       LPUART_CTRL_RIE |                  
                       LPUART_CTRL_ILIE              
                      );               
      LPUART1_BAUD |= (LPUART_BAUD_RDMAE);  
      Serial.print("LPUART1_CTRL=0x"); Serial.println(LPUART1_CTRL,HEX);
      Serial.print("LPUART1_BAUD=0x"); Serial.println(LPUART1_BAUD,HEX);
    }
    
    void loop()
    {
      static uint32_t prev = millis();
      if (dest)
      {
        uint32_t t = millis();
        Serial.print(t - prev); Serial.println(" ms");
        Serial.println((uint32_t)dest, HEX);
        for (int i = 0; i < SAMPLES / 2; i++) Serial.print((char)dest[i]);
        Serial.println();
        prev = t; 
        dest = 0;
      }
    }
    Best Regards,
    HuHu

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    HuHu,

    I am sort of lost with your setup. Looks like you are setting up LPUART1_ And your code looks like you are working Serial2?
    Where on T4 Serial 2 uses LPUART_4... LPUART_1 is used on Serial6 which is Arduino pins 24, 25.

    And yes Uart1 was used on T3.x for Serial2, but not on T4.

    I am actually surprised that your program did not fault before it output the LPUART1, as I don't think the code was called to initialize the "Clock" register which allows access to those registers.
    Something like:
    Code:
    CCM_CCGR5 |= CCM_CCGR5_LPUART1(CCM_CCGR_ON);
    Again there is no information on how you expect the data to come, and the like. I am assuming some external hardware?



    Note: whenever I am working on DMA stuff, I end up hacking in my own Dump the DMA structures, that I use to print out the data. And in several of the libraries it is still there under ifdef.
    Code:
    #ifdef DEBUG_ASYNC_UPDATE
    void dumpDMA_TCD(DMABaseClass *dmabc)
    {
    	Serial.printf("%x %x:", (uint32_t)dmabc, (uint32_t)dmabc->TCD);
    
    	Serial.printf("SA:%x SO:%d AT:%x NB:%x SL:%d DA:%x DO: %d CI:%x DL:%x CS:%x BI:%x\n", (uint32_t)dmabc->TCD->SADDR,
    		dmabc->TCD->SOFF, dmabc->TCD->ATTR, dmabc->TCD->NBYTES, dmabc->TCD->SLAST, (uint32_t)dmabc->TCD->DADDR, 
    		dmabc->TCD->DOFF, dmabc->TCD->CITER, dmabc->TCD->DLASTSGA, dmabc->TCD->CSR, dmabc->TCD->BITER);
    }
    #endif
    
    void ILI9488_t3::dumpDMASettings() {
    #ifdef DEBUG_ASYNC_UPDATE
    #if defined(__MK66FX1M0__) 
    	dumpDMA_TCD(&_dmatx);
    	dumpDMA_TCD(&_dmasettings[0]);
    	dumpDMA_TCD(&_dmasettings[1]);
    	dumpDMA_TCD(&_dmasettings[2]);
    #elif defined(__MK64FX512__)
    	dumpDMA_TCD(&_dmatx);
    //	dumpDMA_TCD(&_dmarx);
    #elif defined(__IMXRT1052__) || defined(__IMXRT1062__)  // Teensy 4.x
    	// Serial.printf("DMA dump TCDs %d\n", _dmatx.channel);
    	dumpDMA_TCD(&_dmatx);
    	dumpDMA_TCD(&_dmasettings[0]);
    	dumpDMA_TCD(&_dmasettings[1]);
    #else
    #endif	
    #endif
    This one came from the ILI9488_t3 library that @mjs513 developed...

    Again this one has the setup to show it's specific setup, for chains of dmasettings... But in your case it would be just the one.
    It has helped me find issues in the past, where maybe a bit was set that I did not expect or ...

    But the first thing is to use the correct LPUART for the Serial port you are wanting to try.

  7. #7
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Update,

    Today I played around some with being able to DMA out a UART...

    I ran into an issue while doing this that found the DMAMUX sources are wrong for T4 UARTS. I updated the cores/teensy4/imxrt.h with fixes.

    More details in the thread: https://forum.pjrc.com/threads/58442...and-Teensy-4-0

  8. #8
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10
    Hi KurtE,

    THX for your quick response!

    Changing LPUART1 to LPUART4 shows a little change:

    LPUART4_BAUD=0x18200064
    LPUART4_CTRL=0x3C0000

    FYI - Serial2 RX is connected to TX of a GPS-module at 9.600 Baud

    Code:
    //===============================
    //  UART Rx to DMA (ping<-->pong)
    //===============================
    
    #include <DMAChannel.h>
    DMAChannel dmaRX(false);
    #define SAMPLES 128
    DMAMEM static uint8_t rx_buffer[SAMPLES];
    volatile uint8_t *dest;
    
    void dmaRXisr(void)
    {
      uint32_t daddr;  
    
      dmaRX.clearInterrupt();  
      daddr = (uint32_t)(dmaRX.TCD->DADDR);
      
      if (daddr < (uint32_t)rx_buffer + sizeof(rx_buffer) / 2)
      {  
        dest = &rx_buffer[SAMPLES / 2]; 
      }   
      else
      { 
        dest = rx_buffer; 
      }
      Serial.print("dmaRXisr: dest=0x"); Serial.println((uint32_t)dest, HEX);
    }
    
    void dmaRXinit()
    {
      dmaRX.begin(true); // Allocate the DMA channel
      dmaRX.source((uint8_t &) LPUART4_DATA); // SERIAL2 = LPUART4 ! ! !
      dmaRX.triggerAtHardwareEvent(DMAMUX_SOURCE_LPUART4_RX);
      dmaRX.destinationBuffer(rx_buffer, sizeof(rx_buffer));
      dmaRX.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
      dmaRX.enable();
      dmaRX.attachInterrupt(dmaRXisr);
    }
    
    void setup()
    {
      Serial.begin(115200);
      
      for (int i = 0; i < SAMPLES; i++)
      {
        rx_buffer[i]=(char)((i%10)+48);
        Serial.print((char)rx_buffer[i]);
        if(i%64==63) Serial.println();
      }  
      Serial.println();
      
      Serial2.begin(9600); // Serial2 = LPUART4 ! ! !
     
      dmaRXinit(); 
    
      LPUART4_BAUD |= (
                       LPUART_BAUD_RDMAE |
                       //LPUART_BAUD_RIDMAE | // not defined, so tried (1<<20), no success
                       0x00000000
                      );
                       
      Serial.print("LPUART4_BAUD=0x"); Serial.println(LPUART4_BAUD,HEX);
      
      LPUART4_CTRL |= (                  
                       LPUART_CTRL_RIE |
                       LPUART_CTRL_ILIE |               
                       LPUART_CTRL_RE |
                       0x00000000
                      );               
    
      Serial.print("LPUART4_CTRL=0x"); Serial.println(LPUART4_CTRL,HEX);
    
    }
    
    void loop()
    {
      static uint32_t prev = millis();
      if (dest)
      {
        uint32_t t = millis();
        Serial.print(t - prev); Serial.println(" ms");
        Serial.println((uint32_t)dest, HEX);
        for (int i = 0; i < SAMPLES / 2; i++) Serial.print((char)dest[i]);
        Serial.println();
        prev = t; 
        dest = 0;
      }
    }
    Any new ideas?

    HuHu

  9. #9
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Did you grab my updated imxrt.h file?

    If not a quick test to see if anything changes:
    Currently you are using: DMAMUX_SOURCE_LPUART4_RX
    Try changing it (temporarily) to use DMAMUX_SOURCE_LPUART4_TX

    And see if anything happens...

  10. #10
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10

    Wink it's getting better

    Quote Originally Posted by KurtE View Post
    Did you grab my updated imxrt.h file?

    If not a quick test to see if anything changes:
    Currently you are using: DMAMUX_SOURCE_LPUART4_RX
    Try changing it (temporarily) to use DMAMUX_SOURCE_LPUART4_TX

    And see if anything happens...
    It's getting better

    First I did a quick test changing "DMAMUX_SOURCE_LPUART4_RX" to "DMAMUX_SOURCE_LPUART4_TX" --> isr is entered now

    After that I replaced the "imxrt.h2 file --> same result, isr is entered

    ..... BUT - no transfer of received data to my buffer - so let's hope for another idea

    serial monitor output + comments:

    Code:
    0123456789012345678901234567890123456789012345678901234567890123 - initial data (first/left half)
    4567890123456789012345678901234567890123456789012345678901234567 - initial data (second/right half)
    
    LPUART4_BAUD=0x18200064
    LPUART4_CTRL=0x3C0000
    
    dmaRXisr: dest=0x20200000 - address (first/left half)
    71 ms - time between loops
    20200000 - address
    0123456789012345678901234567890123456789012345678901234567890123 - still initial data
    
    dmaRXisr: dest=0x20200040 - address (second/right half)
    66 ms - time between loops
    20200040 - address (second/right half)
    4567890123456789012345678901234567890123456789012345678901234567 - still initial data
    
    dmaRXisr: dest=0x20200000 - address (first/left half)
    67 ms - time between loops
    20200000 - address
    0123456789012345678901234567890123456789012345678901234567890123 - still initial data
    
    dmaRXisr: dest=0x20200040 - address (second/right half)
    587 ms - time between loops
    20200040 - address
    4567890123456789012345678901234567890123456789012345678901234567 - still initial data

  11. #11
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    My guess is you might have run into the DMAMEM twilight zone

    That is in the second 512KB of memory is a different memory than the lower 512KB of memory and it has a write back memory caching... The fun of it, is the DMA subsystem does not look at or deal with the cache, it talks directly to the RAM. So when you DMA out of memory you need to tell the system to flush its cache back into physical memory, and when you DMA into memory you need to tell the system to delete the stuff it had in it's cache...

    There is details about this in a few different threads and posts, like:
    https://forum.pjrc.com/threads/54711...l=1#post209340

    Which is also in the thread, I started trying to make sense of memory: https://forum.pjrc.com/threads/57326...l=1#post220632

    A hint from the SPI library code I did.
    Code:
    		if ((uint32_t)retbuf >= 0x20200000u)  arm_dcache_delete(retbuf, count);
    Which sort of says if the return buffer is in high memory than delete the cache....

    Another hint. DMA appears to work better when memory addresses used in DMA are aligned to 32 byte addresses (Learned this from @Frank B). So for example in my ILI9341_t3n, If I am going to allocate a frame buffer which may be used for DMA, I do it like:

    Code:
    			_we_allocated_buffer = (uint16_t *)malloc(CBALLOC+32);
    			if (_we_allocated_buffer == NULL)
    				return 0;	// failed 
    			_pfbtft = (uint16_t*) (((uintptr_t)_we_allocated_buffer + 32) & ~ ((uintptr_t) (31)));

  12. #12
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10

    Smile ... next step --->

    Hi KurtE,

    removed DMAMEM from definition of "rx_buffer" --> seems to be nearly perfect

    Code:
    setup(): dest=0x20000DBC
    0123456789012345678901234567890123456789012345678901234567890123
    4567890123456789012345678901234567890123456789012345678901234567
    
    LPUART4_BAUD=0x18200064
    LPUART4_CTRL=0x3C0000
    prev loop(): 1 Ás
    0123456789012345678901234567890123456789012345678901234567890123
    this loop(): 9 Ás
    dmaRXisr: dest=0x20000DBC
    prev loop(): 995390 Ás
    001.37935,E,1,05,2.98,381.3,M,45.0,M,,*5C$GPGGA,180504.00,4813.8
    this loop(): 8 Ás
    dmaRXisr: dest=0x20000DFC
    prev loop(): 990437 Ás
    6904,N,01301.37934,E,1,05,2.98,381.2,M,45.0,M,,*5F$GPGGA,180505.
    this loop(): 9 Ás
    Last (hopefully) problem I see --> GPS-sentence normally ends with CR/LF, next sentence starts with $GPGGA.

    The CR/LF characters are missing

    Code:
    //===============================
    //  UART Rx to DMA (ping<-->pong)
    //===============================
    
    #include <DMAChannel.h>
    DMAChannel dmaRX(false);
    #define SAMPLES 128
    //DMAMEM static uint8_t rx_buffer[SAMPLES];
    uint8_t rx_buffer[SAMPLES];
    volatile uint8_t *dest;
    
    void dmaRXisr(void)
    {
      uint32_t daddr;  
    
      dmaRX.clearComplete();
      dmaRX.clearInterrupt();  
      daddr = (uint32_t)(dmaRX.TCD->DADDR);
      
      if (daddr < (uint32_t)rx_buffer + sizeof(rx_buffer) / 2)
      {  
        dest = &rx_buffer[SAMPLES / 2]; 
      }   
      else
      { 
        dest = rx_buffer; 
      }
      Serial.print("dmaRXisr: dest=0x"); Serial.println((uint32_t)dest, HEX);
    }
    
    void dmaRXinit()
    {
      dmaRX.begin(true); // Allocate the DMA channel
      dmaRX.source((uint8_t &) LPUART4_DATA); // SERIAL2 = LPUART4 ! ! !
      dmaRX.triggerAtHardwareEvent(DMAMUX_SOURCE_LPUART4_RX); // _TX
      dmaRX.destinationBuffer(rx_buffer, sizeof(rx_buffer));
      dmaRX.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
      dmaRX.enable();
      dmaRX.attachInterrupt(dmaRXisr);
    }
    
    void setup()
    {
      Serial.begin(115200);
      
      dest = rx_buffer;
      Serial.print("setup(): dest=0x"); Serial.println((uint32_t)dest, HEX);
      
      for (int i = 0; i < SAMPLES; i++)
      {
        rx_buffer[i]=(char)((i%10)+48);
        Serial.print((char)rx_buffer[i]);
        if(i%64==63) Serial.println();
      }  
      Serial.println();
      
      Serial2.begin(9600); // Serial2 = LPUART4 ! ! !
     
      dmaRXinit(); 
    
      LPUART4_BAUD |= (
                       LPUART_BAUD_RDMAE |
                       //LPUART_BAUD_RIDMAE | // (1<<20)
                       0x00000000
                      );
                       
      Serial.print("LPUART4_BAUD=0x"); Serial.println(LPUART4_BAUD,HEX);
      
      LPUART4_CTRL |= (                  
                       LPUART_CTRL_RIE |
                       LPUART_CTRL_ILIE |               
                       LPUART_CTRL_RE |
                       0x00000000
                      );          
    
      Serial.print("LPUART4_CTRL=0x"); Serial.println(LPUART4_CTRL,HEX);
    
    }
    
    void loop()
    {
      static uint32_t prev = micros();
      if (dest)
      {
        uint32_t t = micros();
        Serial.print("prev loop(): "); Serial.print(t - prev); Serial.println(" Ás");  
        for (int i = 0; i < SAMPLES / 2; i++)
        {
          Serial.print((char)dest[i]);
          if (dest[i]==13) Serial.print(" ||| CR ||| ");
          if (dest[i]==10) Serial.print(" ||| LF ||| ");  
        }
        Serial.println();
        prev = t; 
        dest = 0;
        Serial.print("this loop(): "); Serial.print(micros() - t); Serial.println(" Ás");
      }
    }
    BTW - is it OK to tag "serial monitor output" as CODE or is there a bettar way?
    Last edited by HuHu; 11-21-2019 at 06:24 PM. Reason: question added

  13. #13
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10

    Unhappy CR and LF/NL characters are dropped

    Hi KurtE,

    any idea why CR and LF/NL characters are dropped? (see previous post)

    Best Regards,
    HuHu

  14. #14
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Nope, maybe not sent by device or are you testing with serial monitor. If monitor what do you have line ending set to?

  15. #15
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10
    Quote Originally Posted by KurtE View Post
    Nope, maybe not sent by device or are you testing with serial monitor. If monitor what do you have line ending set to?
    CR/LF characters are definitely sent by device, I've checked settings for line ending in serial monitor.

    As an additional prove CR/LF are tested in my code and string with corresponding text should be printed.

  16. #16
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Maybe, but maybe it does and is overwritten by next line of text...

    Maybe try something like this to print instead...
    Code:
       for (int i = 0; i < SAMPLES / 2; i++)
        {
          if ((dest[i] >= ' ') && (dest[i] <= '~')) Serial.print((char)dest[i]);
          else Serial.printf("<%02x>", (char)dest[i]); 
        }
    Note could be typos, also if < and > are not obvious choose something else...

  17. #17
    Junior Member HuHu's Avatar
    Join Date
    Nov 2015
    Location
    Austria
    Posts
    10
    Quote Originally Posted by KurtE View Post
    Maybe, but maybe it does and is overwritten by next line of text...

    Maybe try something like this to print instead...
    Code:
       for (int i = 0; i < SAMPLES / 2; i++)
        {
          if ((dest[i] >= ' ') && (dest[i] <= '~')) Serial.print((char)dest[i]);
          else Serial.printf("<%02x>", (char)dest[i]); 
        }
    Note could be typos, also if < and > are not obvious choose something else...
    Sorry for my late reply, there were a lot of other things to do.
    Unfortunately, your suggestion hasn't brought a change.
    But there is a new situation in that sometimes totally wrong data is displayed.
    Sometimes it looks like a lot of characters are missing.
    GPS-sentences start with "$GPGSA", "$GPGLL", "$GPRMC", "$GPVTG"
    Here is an example (serial monitor output):

    Code:
    LPUART4_BAUD=0x18200064
    LPUART4_CTRL=0x3C0000
    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
    dmaRXisr: dest=0x20000DBC
    $R,,,,,5PG,,,3PA,,099,,4PA,,,,,9999993PL,,N4$R,,,,,5PG,,,3
    dmaRXisr: dest=0x20000DFB
    $G,,0099,,8$G,1,,,,9999990$G,,V*$R,,,,,5PG,,,3PA,,099,,4PA,
    dmaRXisr: dest=0x20000DBC
    ,,,,,9999990$G,,V*$R,,,,,5PG,,,3PA,,099,,4PA,,,,,9999993PL,
    dmaRXisr: dest=0x20000DFB
    ,V*$R,,,,,5PG,,,3PA,,099,,4PA,,,,,9999993PL,,N4$R,,,,,5PG,
    dmaRXisr: dest=0x20000DBC
    ,,N0$G,,0099,,8$G,1,,,,9999990$G,,V*$R,,,,,5PG,,,3PA,,099,,4
    dmaRXisr: dest=0x20000DFB
    PG,1,,,,9999990$G,,V*$R,,,,,5PG,,,3PA,,099,,4PA,,,,,9999993
    dmaRXisr: dest=0x20000DBC
    PG,,V*$R,,,,,5PG,,,3PA,,099,,4PA,,,,,9999993PL,,N4$R,,,,,5

  18. #18
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    I will try to take a quick look.

    I did pull out an Adafruit Ultimate GPS unit out of my displays and sensors box...

    I wired it up to T4 to Serial2. Did a quick and dirty sketch:
    Code:
    void setup()
    {
      while(!Serial && millis() < 4000);
      Serial.begin(115200);
      Serial2.begin(9600);
      
    }
    void loop()
    {
      int ch;
      while ((ch = Serial2.read()) != -1) {
        if (ch < ' ') Serial.printf("<%02x>", ch);
        Serial.write(ch);
      }
    }
    And I get continuous lines like:
    Code:
    $GPGSA,A,1,,,,,,,,,,,,,,,*1E<0d>
    <0a>
    $GPGSV,1,1,04,22,,,23,03,,,24,32,,,17,31,,,30*7F<0d>
    <0a>
    $GPRMC,203622.307,V,,,,,0.00,0.00,011219,,,N*44<0d>
    <0a>
    $GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32<0d>
    <0a>
    $GPGGA,203623.307,,,,,0,00,,,M,,M,,*7A<0d>
    <0a>
    $GPGSA,A,1,,,,,,,,,,,,,,,*1E<0d>
    <0a>
    $GPRMC,203623.307,V,,,,,0.00,0.00,011219,,,N*45<0d>
    <0a>
    $GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32<0d>
    <0a>
    Personally I am not sure why you are going through the hassle of DMA, but...

  19. #19
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,702
    Quick update, I am running your sketch, and I am seeing CR and LF...

    That is: Some output:
    Code:
    this loop(): 11 Ás
    dmaRXisr: dest=0x20000D3C
    prev loop(): 67391 Ás
    GGA,204627.000,4825.6559,N,12237.3597,W,1,05,1.99,160.8,M,-17.0,
    this loop(): 11 Ás
    dmaRXisr: dest=0x20000D7C
    prev loop(): 67388 Ás
    M,,*52
     ||| CR ||| 
     ||| LF ||| $GPGSA,A,3,22,03,14,23,01,,,,,,,,2.20,1.99,0.94*08
     ||| CR ||| 
     ||| LF ||| $GPG
    this loop(): 12 Ás
    dmaRXisr: dest=0x20000D3C
    prev loop(): 67387 Ás
    SV,4,1,14,22,80,260,22,03,59,300,22,31,59,081,,14,45,067,19*73
     ||| CR ||| 
     ||| LF ||| 
    this loop(): 12 Ás
    So not sure what you are seeing...

Posting Permissions

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