• AVR Freaks

Hot!PIC32MZ USB device class- interrupt mode issue

Author
NeetaK
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2013/11/15 03:06:26
  • Location: 0
  • Status: offline
2016/07/18 03:20:18 (permalink)
0

PIC32MZ USB device class- interrupt mode issue

I am working on Olimex board for PIC32MZ2048ECG144

I am using the sample code (cdc_com_port_single) provided in the Harmony library for my development. 

The code works good, but what i find is that even though I have set the USB to work in Interrupt mode from Harmony Configurater, i find that if I comment out the function call   
USB_DEVICE_CDC_Read (USB_DEVICE_CDC_INDEX_0,&appData.readTransferHandle, appData.readBuffer,APP_READ_BUFFER_SIZE);

from the stae machine APP_STATE_SCHEDULE_READ & try to enter anything on terminal I dont get any event on the function
APP_USBDeviceEventHandler()
It seems the USB is still in Polling mode instead of Interrupt mode

General understanding is that when USB is in interr mode , the enything entered on the terminal should have generated interrupt & then I can do an read call to collect the data from the USB endpoint

Can anyone please help how I can use the USB in interr mode without using the read() which i believe is Poll based operation

Waiting for favorable reply.

Regards,
Neeta.
#1

8 Replies Related Threads

    RISC
    Super Member
    • Total Posts : 5379
    • Reward points : 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2016/07/18 06:52:40 (permalink)
    0
    Hi,
    Are you using Harmony v1.08.01 (latest version) ?
    Regards
    #2
    NeetaK
    Starting Member
    • Total Posts : 86
    • Reward points : 0
    • Joined: 2013/11/15 03:06:26
    • Location: 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2016/07/18 20:52:51 (permalink)
    0
    Hi,
    No, currently we are using Harmony v1.07.01. But, any hard suggestions on using v1.08.01?

    Regards,
    Neeta.
    post edited by NeetaK - 2016/07/18 20:58:12
    #3
    RISC
    Super Member
    • Total Posts : 5379
    • Reward points : 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2016/07/18 22:51:29 (permalink)
    0
    Hi,
    I just wanted to make sure you were not using a very old version of Harmony.
    Are you using this board for any experimental work and planning to do your own board ? If so, I strongly advise you to consider moving to the PIC32MZ2048EFG144 compatible part instead of PIC32MZ2048ECG144 as many silicon issues were fixed. 
    As far as your issue is concerned have you simply changed from polling to interrupt in MHC and regenerated code or did you change anything in the application code itself ?
    Regards
    #4
    NeetaK
    Starting Member
    • Total Posts : 86
    • Reward points : 0
    • Joined: 2013/11/15 03:06:26
    • Location: 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2016/07/18 23:17:27 (permalink)
    0
    Hi
    Yes we are planning to use it on our own board. Thanks for the suggestion, we will use the PIC32MZ2048EFG144 to avoid the Silicon issues
    We changed from Polling to interrupt by using the MHC
    Actually I found that I do see the event generated for USB_DEVICE_CDC_EVENT_READ_COMPLETE when I do an USB_DEVICE_CDC_Read call
    What I want is actually to also get an interrupt when the first byte of data occurs
    I want to avoid doing this USB_DEVICE_CDC_Read periodically and only will use the call when the interrupt occurs as soon as first byte occurs in the RX buffer of USB EP.

    Regards,
    Neeta.
    #5
    leftShifted
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2016/03/16 22:27:00
    • Location: 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2016/07/29 00:27:44 (permalink)
    0
    Neeta
     
    Your understanding of interrupt mode is not correct. Interrupt mode in harmony only defines if the underlying hardware module (USB in this case) is using interrupts (interrupt mode) or not (polled mode). In interrupt mode, the driver state gets updates from the interrupt service routine. In polled mode, the driver state gets update from SYS_Tasks() function. The fact that you have interrupt mode enabled is good. So don't disable it. Running USB in interrupt mode is always a good thing. Now to answer your other question.
     
    The CDC Device Library is abstracted from the whether the USB Stack is running in interrupt or polled mode. When you commented out the call to USB_DEVICE_CDC_Read, you decided to not provide a buffer to the USB module. This buffer would have stored the data that was sent from the host (when you pressed a key in the terminal).  But now there is no buffer, and so the CDC Device library will tell host that its not ready to receive the data simply because it does not know where to store it. Hence no event!
     
    So here is what you should do. Always call the USB_DEVICE_CDC_Read function at least once and then wait for the USB_DEVICE_CDC_EVENT_READ_COMPLETE. This way you would have provided a buffer to CDC Device Library. You will get the event when data has been received from the host. You will get the event irrespective of whether the stack is operating in interrupt or polled mode. You must treat the event as an interrupt. Note that you should not do computationally intensive "stuff" in the event handler. When you have got the event, set a flag, process your data in the main context and then call USB_DEVICE_CDC_Read when you are ready to receive data again!
     
    Have fun.
     
    LeftShifted
     
    #6
    EmbeddedEngineer
    New Member
    • Total Posts : 26
    • Reward points : 0
    • Joined: 2016/02/24 06:56:35
    • Location: 0
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2019/03/27 06:23:51 (permalink)
    0
    I am working on PIC32MZ2048EFM100 curiosity board I need to implement USB communication but I dont have PID VID where to gets these IDs and what main steps I have to take initiate basic USB communication in device Mode thanks in advance
    #7
    MisterHemi
    Senior Member
    • Total Posts : 178
    • Reward points : 0
    • Joined: 2017/11/02 12:24:21
    • Location: Commerce, CA USA
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2019/11/14 19:38:01 (permalink)
    0
    EmbeddedEngineer
    I am working on PIC32MZ2048EFM100 curiosity board I need to implement USB communication but I dont have PID VID where to gets these IDs and what main steps I have to take initiate basic USB communication in device Mode thanks in advance




    For future reference for you and anyone else, you get the VID (Vendor Identification) from http://usb-if.org
    and the PID is your own number you created to identify your product.

    As of November 2019 the cost of a VID is $6,000 USD. If you become a member of the USB Implementers Forum (USB-IF) I believe the cost is $5,000 USD (per year/annually) but you need to confirm that.
     
    The advantages of becoming a member are access to USB compliance testing (which would be an additional cost if you only get a VID) and access to other benefits, I believe such as early access to standards or being able to give feedback about proposed standards. 

    My configuration:
    MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.14.5) and MPLAB X IDE v5.20
     
    Curiosity PIC32MZ EF, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
    #8
    MisterHemi
    Senior Member
    • Total Posts : 178
    • Reward points : 0
    • Joined: 2017/11/02 12:24:21
    • Location: Commerce, CA USA
    • Status: offline
    Re: PIC32MZ USB device class- interrupt mode issue 2019/11/14 19:41:17 (permalink)
    0
    Correction to the above post. The link should be http://usb.org

    My configuration:
    MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.14.5) and MPLAB X IDE v5.20
     
    Curiosity PIC32MZ EF, PIC24F Curiosity, XPRESS EVAL BOARD (PIC16F18855), SAMA5D3 Xplained and various custom boards.
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5