Hot![SOLVED] PIC32MZ usb transfer

Author
amg
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2014/02/15 11:19:58
  • Location: 0
  • Status: offline
2016/02/03 03:24:00 (permalink)
0

[SOLVED] PIC32MZ usb transfer

Hi all,
 
I am migrating a project from PIC32MX to PIC32MZ, an important part of this project is the USB transfer to PC and vice versa using libusb under linux. The original project with PIC32MX came from an USB Starter Kit 2 example, and some of the main functions were:
 
USB_HANDLE USBTxOnePacket(BYTE ep, BYTE* data, WORD len);
USB_HANDLE USBRxOnePacket(BYTE ep, BYTE* data, WORD len);
BOOL USBHandleBusy(USB_HANDLE handle);
 

 
Before I was using XC32 v1.30, now I have updated to v1.40 and also i've installed the MPlab Harmony Configurator. With all these new libraries and compilers i'm a bit lost and I can't find any USB transfer example for PIC32MZ Starter Kit similar than the one I found for the PIC32MX starter kit.
 
Do you now any place to find some examples about this issue??
Many thanks in advance
post edited by amg - 2016/07/04 09:47:10
#1

15 Replies Related Threads

    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re: PIC32MZ usb transfer 2016/02/03 04:24:02 (permalink)
    0
     
    Was your application based on app note an1164 (usb CDC/com port) or an1166 (generic usb device), or something completely different?
    #2
    amg
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2014/02/15 11:19:58
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/02/03 04:28:31 (permalink)
    0
    It is on an1166 app notes.
    #3
    aburns2
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2016/01/11 09:11:20
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/02/03 07:00:40 (permalink)
    0
    There's a couple of things worth mentioning. One thing is that the peripheral libraries have been removed. I don't know the exact version of where they removed them, but I do know that with v1.40, the peripheral libraries are now a separate download.
     
    Also, I may be wrong on this, but I do believe that most code that ran on the PIC32MX should also run on the PIC32MZ, pending differences in registers and subsystems. So if you wanted to completely get rid of Harmony, I think you can.
     
    As for the USB system, I've always use "M-Stack" for usb support on my PIC32MX's. Technically they only support the MX, but it also says that they may port it to a different chip (such as a MZ) if you ask them; that may be an option for you.
    #4
    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re: PIC32MZ usb transfer 2016/02/03 09:01:53 (permalink)
    0
    aburns2
    There's a couple of things worth mentioning. One thing is that the peripheral libraries have been removed. I don't know the exact version of where they removed them, but I do know that with v1.40, the peripheral libraries are now a separate download.
     
    Also, I may be wrong on this, but I do believe that most code that ran on the PIC32MX should also run on the PIC32MZ, pending differences in registers and subsystems. So if you wanted to completely get rid of Harmony, I think you can.
     
    As for the USB system, I've always use "M-Stack" for usb support on my PIC32MX's. Technically they only support the MX, but it also says that they may port it to a different chip (such as a MZ) if you ask them; that may be an option for you.




    One big difference when migrating from MX to MZ is that any DMA accesses have to take in to account the nature of cached vs. uncached memory, or you have to carefully go through and make sure any buffer that can be read or written by the DMA is declared coherent (uncached).
    #5
    amg
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2014/02/15 11:19:58
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/02/03 09:39:57 (permalink)
    0
    And according to the an1166 notes, Is it possible to migrate this code to MZ "easily" or does it need to use/implement the newer functions from harmony? In the second case, Which note should I follow? Should I use the cdc_usb method instead?
     
    Thanks
    #6
    amg
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2014/02/15 11:19:58
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/03/25 11:12:16 (permalink)
    0
    Hi again,
     
    So, Is there any example of usb bulk transfer on PIC32MZ? I'm migrating a project that was working well in a PIC32MX, I already moved everything but i'm struggling with the USB part, when i started my project under PIC32MX i've followed the an1166 notes but now i'm a bit lost... I wouldn't like to start the USB from zero so i was wondering if there was some starting point or example for this usb mode.
     
    Thanks in advance!
    #7
    newfound
    Super Member
    • Total Posts : 1814
    • Reward points : 0
    • Joined: 2003/11/07 12:35:49
    • Status: offline
    Re: PIC32MZ usb transfer 2016/03/25 15:46:27 (permalink)
    0
    To the very best of my understanding, USB with the MZ requires the use of Hamony as the USB peripherals are so vastly different between the families. At the point in time no one has provided a free standing USB stack for the MZ. It is hamony or bust.
     
    If anyone has any updated information that says otherwise that would be great news and I would love to here it but for now I get the feeling I am right in my belief. 
    #8
    RISC
    Super Member
    • Total Posts : 5375
    • Reward points : 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/03/27 07:50:11 (permalink)
    3 (1)
    Hi,
    The USB peripheral in PIC32MZ is totally different from PIC32MX because it also supports USB HS mode.
    You cannot migrate easily code from PIC32MX to PIC32MZ. the fastest option is to use Harmony USB libraries.
    As for MLA there are plenty of ready made examples for PIC32MZ USB both in device and Host modes.
    After installing Harmony, look here : in....\apps\USB\device\...
    Regards
    #9
    amg
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2014/02/15 11:19:58
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/04/28 03:22:56 (permalink)
    0
    Hi Risc,
     
    Can you suggest me one of these examples for transmit data between pc<->pic?I see many new functions and it was already hard to learn the previous ones... The "vendor" example is the only one i see it can fit.
     
    My application uses linux "libusb" driver on PC:
    PIC->PC:  "Real time" burst sensors data.
    PC ->PIC:  Send orders with short commands.
     
    Many thanks,
    amg
    post edited by amg - 2016/04/28 04:01:17
    #10
    amg
    Starting Member
    • Total Posts : 39
    • Reward points : 0
    • Joined: 2014/02/15 11:19:58
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2016/04/28 08:43:10 (permalink)
    0
    Ok, with the vendor example i have a good starting point. Would be perfect if the PC application  were with libusb instead winusb but is okay.
     
    Thanks!
    #11
    nigelwright7557
    Super Member
    • Total Posts : 181
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2019/02/13 17:38:29 (permalink)
    0
    amg
    Hi again,
     
    So, Is there any example of usb bulk transfer on PIC32MZ? I'm migrating a project that was working well in a PIC32MX, I already moved everything but i'm struggling with the USB part, when i started my project under PIC32MX i've followed the an1166 notes but now i'm a bit lost... I wouldn't like to start the USB from zero so i was wondering if there was some starting point or example for this usb mode.
     
    Thanks in advance!


    I copied across a mx usb code to mz.
    Couple of problems occurred.
    1/ I found I needed a read of a buffer (not used elsewhere) to stop the usb transmit buffer being corrupted.
    2/ When the pc program I was talking to exited after about 5 seconds the mz usb bus would suspend and would freeze.
     
    Update:
    The read of buffer was needed because the USB transmit buffer is DMA'ed and needs to be made uncachable using coherent keyword.
    The USB bus freezing was caused by 2.06 Harmony version, when I went back t o2.04 the problem disappeared.
     
    post edited by nigelwright7557 - 2019/02/24 09:10:47
    #12
    qhb
    Superb Member
    • Total Posts : 9170
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC32MZ usb transfer 2019/02/13 18:34:58 (permalink)
    0
    nigelwright7557
    ...
    1/ I found I needed a read of a buffer (not used elsewhere) to stop the usb transmit buffer being corrupted.

    Possibly that read is causing a RAM cache to be flushed.
    Have you double checked your buffers are located in the correct address segment for cache control?
     
    #13
    MisterHemi
    Junior Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2017/11/02 12:24:21
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2019/02/14 12:18:58 (permalink)
    0
    newfound
    To the very best of my understanding, USB with the MZ requires the use of Hamony as the USB peripherals are so vastly different between the families. At the point in time no one has provided a free standing USB stack for the MZ. It is hamony or bust.
     
    If anyone has any updated information that says otherwise that would be great news and I would love to here it but for now I get the feeling I am right in my belief. 



    An old post, I know... but maybe this would help:
    [url]https://www.microchip.com/forums/m1083508.aspx[/url]
    (USB without Harmony)

    My configuration:
    MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
     
    Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
    #14
    nigelwright7557
    Super Member
    • Total Posts : 181
    • Reward points : 0
    • Joined: 2006/11/06 08:15:51
    • Location: 0
    • Status: offline
    Re: PIC32MZ usb transfer 2019/02/14 14:48:24 (permalink)
    0
    qhb
    nigelwright7557
    ...
    1/ I found I needed a read of a buffer (not used elsewhere) to stop the usb transmit buffer being corrupted.

    Possibly that read is causing a RAM cache to be flushed.
    Have you double checked your buffers are located in the correct address segment for cache control?
     


    I have tried it with coherent and none coherent buffers and the problem persists.
     
    #15
    qhb
    Superb Member
    • Total Posts : 9170
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC32MZ usb transfer 2019/02/14 17:23:48 (permalink)
    0
    You appear to say it was a caching problem in this other topic
    https://www.microchip.com/forums/FindPost/1086484
     
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5