• AVR Freaks

Hot!How to configure SERCOM and UART for ring buffer with MHC?

Author
rdpoor
Starting Member
  • Total Posts : 19
  • Reward points : 0
  • Joined: 2019/06/08 02:17:19
  • Location: 0
  • Status: offline
2020/07/01 18:09:29 (permalink)
0

How to configure SERCOM and UART for ring buffer with MHC?

I'd like to configure my SAME54 SERCOM/UART for ring buffer mode as described in:

    https://microchip-mplab-h...amp;frmfile=07019.html

and whose API is described in:

    https://microchip-mplab-h...amp;frmfile=07022.html

 
However, when instantiating the SERCOM and/or UART in MHC, I don't see any options for selecting Ring Buffer mode.
 
What am I missing?
#1

8 Replies Related Threads

    rdpoor
    Starting Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2019/06/08 02:17:19
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/01 18:14:36 (permalink)
    0
    Since I was was unable tp post graphic in my original message without getting the dreaded "Access Denied" message, here's a link to it:
     
    https://drive.google.com/file/d/1HdTUUzTCnMjWo_vbQYauJe8jsUSgt0iO/view?usp=sharing
     
    #2
    vgandhi
    Senior Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2016/10/24 21:28:35
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/01 21:25:41 (permalink)
    0
    Ring buffer support is added in Harmony CSP v3.7.x release.
    https://github.com/Microchip-MPLAB-Harmony/csp/blob/master/release_notes.md
     
    Which version of CSP are you using?
     
    In CSP v3..x you can find the ring buffer examples available here - https://github.com/Microchip-MPLAB-Harmony/csp/tree/master/apps/sercom/usart/usart_ring_buffer_interrupt
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 18858
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/01 22:20:45 (permalink)
    0
    They added a ring buffer after all these years?
    #4
    vgandhi
    Senior Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2016/10/24 21:28:35
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/01 22:32:28 (permalink)
    0
    Corrected typo:
    In CSP v3.7.x you can find the ring buffer examples available here - https://github.com/Microchip-MPLAB-Harmony/csp/tree/master/apps/sercom/usart/usart_ring_buffer_interrupt
    #5
    rdpoor
    Starting Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2019/06/08 02:17:19
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/02 05:47:14 (permalink)
    0
    I should have mentioned: MHC generates SERCOM code that DOES include functions for Ring Buffer Mode, but the MHC doesn't offer a way to selecte it. 
     
    But to address @vgandhi's question (Pardon this tyro's questions):
    • How do I find what version of CSP I'm running?  Is that the same as the "core" module in the Harmony Content manager?  (Given that the core version number was 3.7.0, I suspect the answer is "yes").
    • How do I update Harmony CSP?  I used Tools => MPLAB Harmony Content Manager and updated "core" to v 3.7.2
    Even after updating core to v 3.7.2, MHC does not present an option for choosing Ring Buffer Mode for the SERCOM. 
     
    Is is possible I'm just using MHC incorrectly?  What I did:
     
    1. I instantiated Peripherals => SERCOM2
    2. I instantiated Tools => STDIO
    3. I connected the UART output of SERCOM2 to the UART input of STDIO.
     
    While this certainly works for printing to the EDBG port of my SAME54 Xplained Pro board, MHC still doesn't offer an option for configuring it in Ring Buffer Mode.
    #6
    rdpoor
    Starting Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2019/06/08 02:17:19
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/02 05:49:36 (permalink)
    0
    Update:
     
    I'm coming to the conclusion that the documentation is simply wrong.  Extracted from the first two links of this thread (emphasis added) is the documentation that sent me down this rabbit hole in the first place:
    The SERCOM UART library also supports ring buffer mode. This mode is available when the peripheral interrupt is enabled and allows data transfer in non-blocking manner. The transmit and receive ring buffer size is configurable in MHC.
    and:
    SERCOMx_USART_ReadCallbackRegister
    Sets the pointer to the function (and it's context) to be called when the given SERCOM_USART's read events occur. This API is only available when SERCOM_USART ring buffer mode is enabled in MHC.
    As far as I can tell, the MHC cannot configure the ring buffer size, nor can you "enable ring buffer mode" using MHC.  If I'm wrong about this, please let me know!
     
    In the meantime, I'm perfectly able to configure the SERCOM using the provided API calls.  My only regret is the hours I lost while trying to obey the documentation.  Sigh.
     
    post edited by rdpoor - 2020/07/02 06:03:55
    #7
    vgandhi
    Senior Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2016/10/24 21:28:35
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/02 07:25:11 (permalink)
    0
    1. How to know the version of csp? Go to your Harmony folder and look for the "csp" folder. Inside this folder open the release_notes.md file. You should be able to see the version information of csp in the first few lines. Updating core package should download the csp v3.7.x.
    2. The ring buffer feature is part of the csp package. Unless the csp package is up-to-date (v3.7.x), the ring buffer option will not be available in the MHC configurator.
    3. The ring buffer mode is only available when the SERCOM USART interrupt is enabled. When STDIO is connected to SERCOM USART, the interrupt is disabled as STDIO does a blocking read/write using the SERCOM USART APIs. This means that the ring buffer functionality will not be available when STDIO is connected to SERCOM USART. Also, note that the ring buffer mode is currently not supported with UART driver. 
    4. As far as the documentation is concerned, there are two versions of the  SERCOMx_USART_ReadCallbackRegister API. One version takes callback of type "SERCOM_USART_CALLBACK" and is available when the ring buffer is disabled. The second version takes callback of type "SERCOM_USART_RING_BUFFER_CALLBACK" and is available when the ring buffer is enabled.
    #8
    rdpoor
    Starting Member
    • Total Posts : 19
    • Reward points : 0
    • Joined: 2019/06/08 02:17:19
    • Location: 0
    • Status: offline
    Re: How to configure SERCOM and UART for ring buffer with MHC? 2020/07/02 07:47:26 (permalink)
    0
    @vgandhi:
     
    Thank you for the useful info on ring buffer mode, and I've started to use the API calls that you describe.
     
    My only remaining issue is that the documents are simply wrong: they state that the MHC is responsible for enabling ring buffer mode.  It has become obvious that is not the case -- see my previous Update: note.  (Yes, I understand that you must enable interrupts for Ring Buffer mode, and that is done using MHC, but the rest of the docs are misleading at best.)
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5