Hi Folks -
I’ve been building some sensor circuits using Xiao for some time, but have really struggled finding documentation to solve my current problem. If this answer exists elsewhere sorry in advance. I’m pretty much a noob on registry meddling and interrupts though and that’s why I’m struggling below.
I’m trying to build a guitar pedal using xiao as the microcontroller. I am following the pedalshield Uno design from Electrosmash. I successfully got this working on my Uno, using the code posted on this link:
electrosmash pedalshield uno clean/transparent
This won’t compile for the Xiao (yes I’ve changed the board to Xiao in the arduino IDE), and is throwing errors particularly around the interrupts.
So couple questions.
- How do I convert this into something that will run on the Xiao? It’s important to get the values from the registry and on the interrupt call to minimize lag. I’m seeing significant lag in basic IO using analogRead/analogWrite.
ISR(TIMER1_CAPT_vect)
{
// get ADC data
ADC_low = ADCL; // you need to fetch the low byte first
ADC_high = ADCH;
//construct the input sumple summing the ADC low and high byte.
input = ((ADC_high << 8) | ADC_low) + 0x8000; // make a signed 16b value//write the PWM signal
OCR1AL = ((input + 0x8000) >> 8); // convert to unsigned, send out high byte
OCR1BL = input; // send out low byte}
- Would love to use the DAC on pin A0 for the output and thus skip PWM, How would I incorporate that? Seems like I could use the analogWrite(A0,XXX) but again I’m looking for something very fast.
THanks in advance for your comments.