Page 1 of 1

Help with USB Serial on an 18F4550

Posted: Thu Jun 08, 2017 7:35 pm
by TSMroz
Hi, I realize that USB Slave is currently not working in V7, but is the USB serial component stable? Here's what I'm trying to do in a separate simple test case:

I've basically replicated the LED blink program in a loop (turn <any> port bit on, add a delay, turn same port bit back off, add another delay). My delays are both 100 uS. The program works as expected and my pulse widths are correct.

Now, if I add the USB_Serial component to my project, everything still works fine. But, if I drag and drop the "USB_Serial::Initialise" macro to the top of my program (yes, outside the loop) and run it, both my negative and positive pulse widths are no longer stable. They randomly vary between ~106 (expected) up to 122 or so. If I disable the Initialise, the signal goes back to being stable again. Likewise, if leave in the Initialise, but simply remove the USB cable, they also go back to being stable.

I've tried both 4Mhz and 16Mhz oscillators with no change. Problem is, I need both USB connectivity and the stable GPIO pulse widths for my project. The PW variances are causing random misreads on my other port bits due to the mistiming. Maybe there's something I'm overlooking.


Thanks

Re: Help with USB Serial on an 18F4550

Posted: Thu Jun 08, 2017 8:30 pm
by kersing
The USB components all use interrupts to service the USB protocol. Those interrupts will cause the observed timing variations but can not be avoided without violating USB timing requirements (making the device drop of the USB bus). For exact timing you will need to use hardware PWM.

Re: Help with USB Serial on an 18F4550

Posted: Thu Jun 08, 2017 8:38 pm
by TSMroz
Thank you, appreciate the response. I was wondering if it was something along those lines and unavoidable. I haven't learned the hardware PWM side yet.. So with that I can create single control pulses in the sub-millisecond ranges? Great if so. I'm more concerned with the timing of my entire port B bus readings that I need to perform, but will tackle that after I figure out the PWM stuff. Thanks again!

Oh, I figure there's probably another way of using the timers or an interrupt or both to create accurate pulses as well? I'm still trying to figure that out as well. My single port bit pulse width actually needs to be a single 34 uS pulse, when called, to toggle another part of my circuit. That's the most critical one. The others don't really need to be as exact.

Re: Help with USB Serial on an 18F4550

Posted: Wed Jun 14, 2017 9:55 am
by Benj
I realize that USB Slave is currently not working in V7
We are currently working on the USB side of things and hope to have things back up and running well soon.

And yes while we are doing this we are also looking into USB device support for the PIC32 and STm32 devices.

Re: Help with USB Serial on an 18F4550

Posted: Wed Jun 14, 2017 1:08 pm
by TSMroz
Great news. Thanks again!