1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

USB timing

Discussion in 'Oshonsoft' started by ColinE, Jul 27, 2014.

  1. ColinE

    ColinE New Member

    Joined:
    Mar 13, 2013
    Messages:
    19
    Likes:
    0
    I have a project that requires a USB interface, but also has to process events on a strict timer schedule.

    So does anybody know the maximum number of cycles that the USB interface will take, before releasing control back to the main code?

    What I'm after is three PWM outputs, with 8 bit resolution at greater than 250Hz, which only gives 16uS steps.
     
  2. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    You can do one of these:

    1) Use hardware modules for PWM. Most PICs have them. Look for CCP or OC. All the PWM will be done in the hardware and you can get busy doing USB at your own pace.

    2) Create a timer interrupt and process your PWMs inside the interrupt. The USB code will run in the background and your interrupt will interrupt it when needed.
     
  3. ColinE

    ColinE New Member

    Joined:
    Mar 13, 2013
    Messages:
    19
    Likes:
    0
    1) I need three PWMs and I can't find a PIC that has that and USB.

    2) Now that could well be the answer. Many thanks.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,149
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE

    Try a combo....

    The pic16f14XX has 2 PWM hardware modules..... So USB and two hardware PWM's.. Then one software PWM

    Can't you use a pic18f26j53... This has 7 CPP modules
     
  6. ColinE

    ColinE New Member

    Joined:
    Mar 13, 2013
    Messages:
    19
    Likes:
    0
    Thanks, but this design has to be as cheap as possible, as we'll be building thousands.

    So the remaining question is: Will the USB code work with interrupts enabled?
     
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,149
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    The short answer is yes!

    As long as you call the HID service as often as you can...
     
  8. ColinE

    ColinE New Member

    Joined:
    Mar 13, 2013
    Messages:
    19
    Likes:
    0
    Thanks a lot. That's been very helpful.
     

Share This Page