Skip to content
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

Does the wokwi simulator support the round-robin method of reading multiple ADC channels in pico? #141

Open
rmoh12 opened this issue May 28, 2024 · 2 comments

Comments

@rmoh12
Copy link

rmoh12 commented May 28, 2024

Hi, I tried to change the dma_capture pico sdk example code to read multiple ADC inputs in a round-robin method, but only ADC0(pin26) is read. All my efforts to implement this method in wokwi simulator ended with the same result. at the address
https://forums.raspberrypi.com/viewtopic.php?t=350378
I saw that this work was done. So I tried to run the final code in the wokwi simulator, but the result was the same, that is, only ADC0 (pin26) is read.
https://wokwi.com/projects/399099758831776769
It seems that the wokwi simulator does not support the round robin method for pico. Please guide me if anyone has any information on this matter. Thankful

@urish
Copy link
Contributor

urish commented May 28, 2024

Hi! The ADC does seem to implement multi-shot read in a round robin fashion, but I'm not sure how well tested this specific code path is. If you are interested, you can take a look at the implementation here:

const round = (this.cs >> CS_RROBIN_SHIFT) & CS_RROBIN_MASK;
if (round) {
let channel = this.activeChannel + 1;
while (!(round & (1 << channel))) {
channel = (channel + 1) % this.numChannels;
}
this.activeChannel = channel;
}
// Multi-shot conversions
if (this.cs & CS_START_MANY) {
const clockMHZ = 48;
const sampleTicks = clockMHZ * this.sampleTime;
if (this.divider > sampleTicks) {
// clock runs at 48MHz, subtract 2uS
const micros = (this.divider - sampleTicks) / clockMHZ;
this.multiShotAlarm.schedule(micros * 1000);
} else {
this.startADCRead();
}
}

@rmoh12
Copy link
Author

rmoh12 commented May 29, 2024

hi, thank you for your reply.
I did not work much in the field of java script. I looked at the part of the code you gave. It doesn't seem like there is a problem with that part. But it is important what value is passed to the writeUint32 function in the value and offset parameters. As a result, the behavior of the program should be checked at the time of execution. I don't know what the main code of the program is or how to run it. For the sake of it, I decided to test my code in the real environment. It really worked. But not in the wokwi simulator. So we must have a problem here and the wokwi simulator does not work properly in the round robin method. I really don't know how to fix it.
I remind you that I am not very fluent in Java, but if you can guide me on how to run this simulator in the vs code environment, I might be able to help.
If not, I think someone should bother to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants