View previous topic :: View next topic |
Author |
Message |
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
USB CDC support for PIC24FJ32GU205 |
Posted: Mon Nov 20, 2023 6:33 pm |
|
|
Hello Everyone,
I am starting a new project where I want to use the PIC24FJ32GU205 to implement a USB CDC so I can send serial data from another device to the computer through this MCU. Does CCS have drivers/code to implement USB CDC functionality?
Thanks for your feedback,
O. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Nov 21, 2023 3:02 am |
|
|
Yes.
Standard driver with the compiler. usb_cdc.h
Assuming you have a modern compiler, the usb_serial example has been
rewritten to support the DS PIC's. About 2010, then some issues fixed
in 2013!....
Look at the usb_serial examples. |
|
|
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
|
Posted: Tue Nov 21, 2023 9:23 am |
|
|
Hi Ttelmah,
I have the PCWHD version 5.116 (I have been compiling code for the PIC24FJ32GU205) so I think this is the modern version - correct?
Thanks for your response. I do see the driver and examples.
Has CCS tested the driver and examples on this newer device (PIC24FJ32GU205)? You mentioned some issues had been fixed in 2013 but I want to say the PIC24FJ32GU205 was released after that (correct me if I'm wrong).
Thank you again,
O. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Nov 21, 2023 12:06 pm |
|
|
The basic USB stack doesn't change with chips. The problems were issues
with moving from the older chips. |
|
|
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
|
Posted: Tue Nov 21, 2023 12:08 pm |
|
|
Sounds good!
As always, great support.
Thank you.
O. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Nov 22, 2023 6:47 am |
|
|
As a comment, some remarks about USB in general.
Keep your connections on the board short, each close to the same length,
and make sure the track spacing is correct for the characteristic impedance.
For USB2, the connection length should not exceed 25mm.
Make sure you add detection for the connection being made.
The drivers on your chip meet the impedance spec. So no termination
required. |
|
|
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
|
Posted: Wed Nov 22, 2023 8:18 am |
|
|
Hi Ttelmah,
I appreciate the additional recommendations. I am not totally familiar with the various USB connection standards but as I'm going to be bridging at most 1Mbaud serial data I would want to connect with Full Speed (12 Mb/s) USB. I suspect a signaling rate of 12 Mb/s should not require very strict differential pair (USB +D/-D) routing requirements. Maybe I'm wrong on that - what do you think?
I certainly do not plan on using USB2.0, as I read through the PIC24FJxxGU spec I don't see USB having USB2.0 capability. It does have what they call 'USB On-The-Go" but not sure that's higher than 12 Mb/s signaling rate.
thanks,
O. |
|
|
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
|
Posted: Wed Nov 22, 2023 8:24 am |
|
|
I forgot to add one question: You mentioned that I should add detection. Is that a SW thing or is that an actual pin on the PIC24FJ32GU205 that needs to be connected to something?
The pinout on this device, regarding USB related connections, only has USBOEN_, Vbus, Vusb3v3, and USBID (apart from D+/D-).[/img] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Nov 22, 2023 10:58 am |
|
|
Both.
It means there has to be a physical connection to the USB V+ line, and the
software has to be told what pin to use for this sensing. On the DsPIC's,
you normally do it with the Vbus pin, and the VBUSVD bit. You setup a
USB_CABLE_IS_ATTACHED macro, before loading the USB driver to test
this bit.
This is _required_ by the USB specs, unless the device is only powered
by the USB bus (so switches off when disconnected). |
|
|
robleso7473
Joined: 25 Mar 2009 Posts: 47
|
|
Posted: Wed Nov 22, 2023 11:22 am |
|
|
Hi Ttelmah,
Yes, I've had USB V+ connected VUSB pin on MCU from the beginning. I do understand this is required or recommended.
Thanks,
O. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Nov 23, 2023 6:17 am |
|
|
Good.
A lot of people don't realise this is required. |
|
|
|