• AVR Freaks

Hot!UART issue - Harmony 2.06

Author
Rafauy
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2015/07/16 10:38:53
  • Location: 0
  • Status: offline
2019/08/21 08:00:56 (permalink)
0

UART issue - Harmony 2.06

Hi,
 
I am receiving a very long datastream at 115200bps, its size is around 1MByte. The MCU is a PIC32MZ2048EFM144, the configuration is the following:
UART 3 is configured for buffer queue transfer model, where the expected reception size is 1 byte ((DRV_USART_BufferAddRead(1 byte)). Interrupt mode is enabled, so in the ISR a following 1 byte read request is added (See code below).
The interrupt priority for this USART is the highest (7-3) and is the only assigned this priority. I need to do it this way because I get the data from a WiFi module and some parsing has to be done on the fly.
 
My problem is that after receiving some data (could be hundreds of bytes up to hundreds of thousands of bytes) the reception halts. The interruption stops happening.
 
I dont think this could be caused by an UART overrun given the interruption priority (I am aware of the silicon issue with this PIC). I have also checked the bits FERR, OERR, and PERR and none was set after the halt.
Ive seen similar posts about this issue, has somebody found a workaround?
Now I am considering using PLIBs or using the DMA to handle the data, which would you recommend?
 
 
void WIF_bufferEventHandler(DRV_USART_BUFFER_EVENT event, DRV_USART_BUFFER_HANDLE bufferHandle, uintptr_t contextHandle) {
if(wifiObj.rxBufferHandle == bufferHandle) {
wifiObj.rxBufferIndex++;
if(wifiObj.rxBufferIndex == rxBufferSizeWifi) {
wifiObj.rxBufferIndex = 0;
}
DRV_USART_BufferAddRead(wifiObj.wifiHandle, &(wifiObj.rxBufferHandle), &(wifiObj.rxBuffer[wifiObj.rxBufferIndex]), 1);
}
else if(wifiObj.txBufferHandle == bufferHandle) {
wifiObj.txCompleted = true;
}
return;
}

#1

5 Replies Related Threads

    BillP
    Super Member
    • Total Posts : 337
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: UART issue - Harmony 2.06 2019/08/21 13:18:47 (permalink)
    0
    I have had problems using the buffer queue model in the past, so for single byte transfers I use the byte mode model and have never had a problem at 115,200 (but I have not transferred a 1 MB file either).  Try the byte mode.
     
    Here are the basics for storing data in a circular buffer of size = SERIAL_CIRCBUFSIZE.
     
    char rbuf[SERIAL_CIRCBUFSIZE];
    int putbyte=0;  // next byte number in circular buffer to store data


    serialData.usartHandle = DRV_USART_Open(DRV_USART_INDEX_0, DRV_IO_INTENT_READWRITE|DRV_IO_INTENT_NONBLOCKING|DRV_IO_INTENT_EXCLUSIVE);
                    DRV_USART_ByteReceiveCallbackSet(DRV_USART_INDEX_0, RXEventHandler);
                    DRV_USART_ByteErrorCallbackSet(DRV_USART_INDEX_0, ErrorEventHandler);

    void RXEventHandler(const SYS_MODULE_INDEX index)
    {
        // a byte has been received.  Store it in the rbuf    
        rbuf[putbyte] = DRV_USART_ReadByte(serialData.usartHandle);
        // update the counter and account for wrap-around
        putbyte++;
        if(putbyte >= SERIAL_CIRCBUFSIZE) putbyte = 0;    
    }

    void ErrorEventHandler(const SYS_MODULE_INDEX index)
    {
        serialData.state = SERIAL_STATE_READWRITEERROR;
    }



     
    #2
    snchlsn
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/01/11 16:56:47
    • Location: 0
    • Status: offline
    Re: UART issue - Harmony 2.06 2019/09/16 15:15:21 (permalink)
    0
    The interrupt priority for this USART is the highest (7-3)

     
    In the MIPS architecture, interrupt priorities are the reverse of the numerical ordering. Thus, the highest priority is 1-0.
    #3
    BillP
    Super Member
    • Total Posts : 337
    • Reward points : 0
    • Joined: 2014/09/28 07:53:35
    • Location: CA
    • Status: offline
    Re: UART issue - Harmony 2.06 2019/09/16 15:39:22 (permalink)
    0
    In the PIC32MX Family Reference Manual, Section 8.7.1 it shows the highest priority is 7 and a level = 0 is disabled.
    #4
    snchlsn
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/01/11 16:56:47
    • Location: 0
    • Status: offline
    Re: UART issue - Harmony 2.06 2019/09/16 16:11:48 (permalink)
    0
    ... You're right. I'm glad I checked this thread. I've been programming PICs for years, and have no clue how I got that mixed up.
     
    Well, moving on: The Harmony docs strongly advise against calling PLIB functions in application code, since the API is liable to change as Harmony is updated, making DMA the better option for best practice.
    #5
    Paul PortSol
    Super Member
    • Total Posts : 512
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: UART issue - Harmony 2.06 2019/09/17 05:40:27 (permalink)
    0
    I suggest using Byte Model with Rx Callbacks, works fine for me with 20K packets (1M is extreme for single packet)
    - Note that there have been issues with enabling UART Error Interrupts, so I keep them disabled
    - I direct Tx when FIFO has space from my own ringbuffers (Checked once per 'task' pass in state machine)
    - The callback takes from Rx FIFO to my own ringbuffer, then non-interrupt code handles processing.
    - Best to process data outside interrupt to avoid timing issues (minimize interrupt service time to remove glitches for all interrupts)
    Paul
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5