-
Notifications
You must be signed in to change notification settings - Fork 1.3k
samd51: DAC: Make clock usage more like Arduino core #2104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This improves the behavior around adafruit#1992. The samples stay in sync now, though full scale changes still behave erratically. Testing performed: On a Metro M4, with both analog channels going to a scope, I looked for synchronization and waveform shape. Original reproducer: Stays synchronized. adafruit#1992 (comment) reproducer: Stays synchronized and plays at the nominal 100kHz sample rate. However, waveform peaks are "regularly irregular", with every other high peak being truncated, usually. A difference I'm aware of between this and Arduino's M4 core is that Arduino uses CCTRL_CC100K; however, doing this makes CP worse, so I went with the more "correct" CC12M setting. Closes: adafruit#1992
lol - out of curiosity, do you have a 'mimic' set up with arduino for this kind of output? what if you do [0, 1000] is it the 65535 thats messing it up? |
@ladyada The screenshot above is from a CircuitPython program with my patch:
My arduino program:
|
🤷♀ i just play 20khz max audio thru this thing :D |
The rise/fall rate seems to have to do with the CCTRL register:
One thing I notice is that when doing analogWrite, Arduino does this:
in CP AnalogOut, we're not looking at READY0 or DATA0. Ardino also doesn't use LEFTADJ but that doesn't seem to be the source of the problem. |
@ladyada I think 20kHz sample rate audio works pretty good, especially if it's also mono. Stereo, very high sample rates, and unusual waveforms are where the problems @kevinjwalters reports seem to enter the picture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Have you done a diff of the DAC's registers between CircuitPython and Arduino? I'd be curious if it shows anything.
@tannewt don't merge yet, I think this change may have adversely affected sqpi flash I/O and need to do further checking to exclude that theory. Yes, I do have a diff of DAC registers but it's not handy. Ping me again if I don't attach it. |
Kk, looks like it didn't run the checks either... |
Huh I wonder why it didn't run checks. |
If you merge from upstream and push, it will run the checks. That has worked for me. |
Where are we at on this? |
Needs more testing on my part, I had inconclusive results |
I am closing this in favor of a new PR to be issued shortly. |
This improves the behavior around #1992. The samples stay in sync now, though full scale changes still behave erratically.
Testing performed: On a Metro M4, with both analog channels going to a scope, I looked for synchronization and waveform shape.
Original reproducer: Stays synchronized.
#1992 (comment) reproducer: Stays synchronized and plays at the nominal 100kHz sample rate. However, waveform peaks are "regularly irregular", with every other high peak being truncated, usually.
A difference I'm aware of between this and Arduino's M4 core is that Arduino uses CCTRL_CC100K; however, doing this makes CP worse, so I went with the more "correct" CC12M setting.
Closes: #1992