I just wanted to provide an update for those of you with similar problems. Look in the usb_start.c file provided. There is an example of an echo program that echos back what it receives.
The architecture is built entirely on callbacks. Apparently USB has a 64-byte payload maximum, too. Ringbuffers come up frequently in this sort of application when I was searching for longer inputs if needed.
Apparently after a write a read needs to be called to have an empty buffer "waiting".
The application notes on the USB CDC ACM are outdated at best and I found no documentation on the provided functions. I have however managed to get the example to function.
Things to check:
- 1. Ensure USB is receiving 48MHz. If you're using the internal clock you need to turn on clock recovery mode.
- 2. Main CPU clock has to be fast enough to process the incoming transaction. I think I managed to get it as low as 24MHz. Lower than that it was not reliable at least with my configuration (based on internal oscillator).
- 3. Ensure that clocks are actually enabled. There is a checkbox. Easy to miss.
- 4. In prior versions (SAMD11) there is an interrupt on the USB driver that prevented operation of the middleware. Check that if you run into weird behavior.
- 5. If configured properly the USB will enumerate as a Atmel example device. (Check device manager in windows). You can change the enumeration in the middleware options. 0x0 I think it was is the generic VID that will remove the company name there. Not sure the ramifications of providing this VID. USB-IF has a registration process. I'm only doing testing as a hobby project so not worried about this.
- 6. If you are working on a big project, make a copy of it, launch that, and work on getting the basics of USB working. ("Smallest reproducible example"). This will remove a lot of headache.
Hopefully this helps someone in a similar situation.
Helpful resources (Some literal plug and play examples here):
-
https://github.com/davepruitt/samd_tutorials -
-
https://gitlab.com/nystrom.fredric/samd51-asf4-usbserial/-/tree/master?ref_type=heads - SAMD51 ASF4 USB Serial
-
- SAMD51 with Atmel Start: a better USB virtual serial port ( David Pruitt)
Applicability: (What I used to get to this point)
- Microchip Studio V7.0.2594 / Atmel Kits 7.0.132
- Project created with Atmel Start
- Created project July 2024 using "latest" from Microchip Studio.
- May not be applicable to MPLab/Harmony IDE with Atmel plugin. Have not tried it.