Testbild-synth / HAGIWO-029-033-Eurorack-quantizer

Through hole PCB version of the HAGIWO Dual Quantizer/SH101 Sequencer Eurorack Module-.
MIT License
26 stars 6 forks source link

Can't compile Arduino Quantizer code due to various errors #1

Closed guytanium closed 1 year ago

guytanium commented 1 year ago

Hey! I just finished building this module. I am not sure how to resolve the issues trying to flash my Xiao RP2040. First I was having issues with Encoder interrupts (which I turned off) and now can't seem to pick up anything associated with ADC or PWM.

First I updated all libraries then I installed arduino-pico into Boards Manager. "Seeed XIAO RP2040" selected in Raspberry Pi RP2040 Boards(2.6.2) under the Boards menu.

Then I manually updated Encoder to 1.4.3, only 1.4.2 shows in Arduino Library Manager. I was getting errors that interrupts are not supported such as: /Users/guy/Documents/Arduino/libraries/Encoder/utility/interrupt_pins.h:390:2: error: #error "Interrupts are unknown for this board, please add to this code" 390 | #error "Interrupts are unknown for this board, please add to this code" | ^~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/utility/interrupt_pins.h:393:2: error: #error "Encoder requires interrupt pins, but this board does not have any :(" 393 | #error "Encoder requires interrupt pins, but this board does not have any :(" | ^~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/utility/interrupt_pins.h:394:2: error: #error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge." 394 | #error "You could try defining ENCODER_DO_NOT_USE_INTERRUPTS as a kludge."

So I switched #define ENCODER_OPTIMIZE_INTERRUPTS to ENCODER_DO_NOT_USE_INTERRUPTS to get past this error.

Next set of errors WARNING: library FlashStorage claims to run on samd architecture(s) and may be incompatible with your current board which runs on rp2040 architecture(s). In file included from /Users/guy/Downloads/double_quantizer/double_quantizer.ino:13: /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:68:11: error: 'IO_REG_TYPE' does not name a type; did you mean 'IP_GET_TYPE'? 68 | volatile IO_REG_TYPE * pin1_register; | ^~~~~~~~~~~ | IP_GET_TYPE /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:69:11: error: 'IO_REG_TYPE' does not name a type; did you mean 'IP_GET_TYPE'? 69 | volatile IO_REG_TYPE * pin2_register; | ^~~~~~~~~~~ | IP_GET_TYPE /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:70:2: error: 'IO_REG_TYPE' does not name a type; did you mean 'IP_GET_TYPE'? 70 | IO_REG_TYPE pin1_bitmask; | ^~~~~~~~~~~ | IP_GET_TYPE /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:71:2: error: 'IO_REG_TYPE' does not name a type; did you mean 'IP_GET_TYPE'? 71 | IO_REG_TYPE pin2_bitmask; | ^~~~~~~~~~~ | IP_GET_TYPE /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h: In constructor 'Encoder::Encoder(uint8_t, uint8_t)': /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:89:11: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register' 89 | encoder.pin1_register = PIN_TO_BASEREG(pin1); | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:89:27: error: 'PIN_TO_BASEREG' was not declared in this scope 89 | encoder.pin1_register = PIN_TO_BASEREG(pin1); | ^~~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:90:11: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask' 90 | encoder.pin1_bitmask = PIN_TO_BITMASK(pin1); | ^~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:90:26: error: 'PIN_TO_BITMASK' was not declared in this scope 90 | encoder.pin1_bitmask = PIN_TO_BITMASK(pin1); | ^~~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:91:11: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register' 91 | encoder.pin2_register = PIN_TO_BASEREG(pin2); | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:92:11: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask' 92 | encoder.pin2_bitmask = PIN_TO_BITMASK(pin2); | ^~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:99:31: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register' 99 | if (DIRECT_PIN_READ(encoder.pin1_register, encoder.pin1_bitmask)) s |= 1; | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:99:54: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask' 99 | if (DIRECT_PIN_READ(encoder.pin1_register, encoder.pin1_bitmask)) s |= 1; | ^~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:99:7: error: 'DIRECT_PIN_READ' was not declared in this scope 99 | if (DIRECT_PIN_READ(encoder.pin1_register, encoder.pin1_bitmask)) s |= 1; | ^~~~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:100:31: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register' 100 | if (DIRECT_PIN_READ(encoder.pin2_register, encoder.pin2_bitmask)) s |= 2; | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:100:54: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask' 100 | if (DIRECT_PIN_READ(encoder.pin2_register, encoder.pin2_bitmask)) s |= 2; | ^~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:100:7: error: 'DIRECT_PIN_READ' was not declared in this scope 100 | if (DIRECT_PIN_READ(encoder.pin2_register, encoder.pin2_bitmask)) s |= 2; | ^~~~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h: In static member function 'static void Encoder::update(Encoder_internal_state_t*)': /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:303:40: error: 'struct Encoder_internal_state_t' has no member named 'pin1_register' 303 | uint8_t p1val = DIRECT_PIN_READ(arg->pin1_register, arg->pin1_bitmask); | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:303:60: error: 'struct Encoder_internal_state_t' has no member named 'pin1_bitmask' 303 | uint8_t p1val = DIRECT_PIN_READ(arg->pin1_register, arg->pin1_bitmask); | ^~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:303:19: error: 'DIRECT_PIN_READ' was not declared in this scope 303 | uint8_t p1val = DIRECT_PIN_READ(arg->pin1_register, arg->pin1_bitmask); | ^~~~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:304:40: error: 'struct Encoder_internal_state_t' has no member named 'pin2_register' 304 | uint8_t p2val = DIRECT_PIN_READ(arg->pin2_register, arg->pin2_bitmask); | ^~~~~~~~~~~~~ /Users/guy/Documents/Arduino/libraries/Encoder/Encoder.h:304:60: error: 'struct Encoder_internal_state_t' has no member named 'pin2_bitmask' 304 | uint8_t p2val = DIRECT_PIN_READ(arg->pin2_register, arg->pin2_bitmask); | ^~~~~~~~~~~~ /Users/guy/Downloads/double_quantizer/double_quantizer.ino: In function 'void setup()': double_quantizer:94:2: error: 'REG_ADC_AVGCTRL' was not declared in this scope 94 | REG_ADC_AVGCTRL |= ADC_AVGCTRL_SAMPLENUM_1; | ^~~~~~~~~~~~~~~ double_quantizer:94:21: error: 'ADC_AVGCTRL_SAMPLENUM_1' was not declared in this scope 94 | REG_ADC_AVGCTRL |= ADC_AVGCTRL_SAMPLENUM_1; | ^~~~~~~~~~~~~~~~~~~~~~~ double_quantizer:95:2: error: 'ADC' was not declared in this scope 95 | ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_128 | ADC_AVGCTRL_ADJRES(4); | ^~~ double_quantizer:95:21: error: 'ADC_AVGCTRL_SAMPLENUM_128' was not declared in this scope 95 | ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_128 | ADC_AVGCTRL_ADJRES(4); | ^~~~~~~~~~~~~~~~~~~~~~~~~ double_quantizer:95:49: error: 'ADC_AVGCTRL_ADJRES' was not declared in this scope 95 | ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_128 | ADC_AVGCTRL_ADJRES(4); | ^~~~~~~~~~~~~~~~~~ /Users/guy/Downloads/double_quantizer/double_quantizer.ino: In function 'void PWM1(int)': double_quantizer:722:2: error: 'pwm' was not declared in this scope 722 | pwm(ENV_OUT_PIN_1, 46000, duty1); | ^~~ /Users/guy/Downloads/double_quantizer/double_quantizer.ino: In function 'void PWM2(int)': double_quantizer:725:2: error: 'pwm' was not declared in this scope 725 | pwm(ENV_OUT_PIN_2, 46000, duty2); | ^~~ exit status 1 'REG_ADC_AVGCTRL' was not declared in this scope

Are you using a different set up in board manager? It looks like Arduino IDE doesn't know anything about the pinouts or environment for RP2040. Thanks

Testbild-synth commented 1 year ago

hi @guytanium , the problem is probably that you are using an RP2040 instead of a regular Xiao, which has a Samd21/cortex m0 chip. Seed studios has kind of confusing naming conventions for the uC boards, but they are two entirely different products. (there is also a xiao esp32 which is yet another different thing altogether)

Hagiwo made the code for the Xiao with the samd21 chip and you will probably have to manually change a bunch of things related to the dac/adc settings if you want to run it on an RP2040 (not even sure if the pins match). I will update the BOM to reflect this more closely in the future

Testbild-synth commented 1 year ago

if you want to try using the 2040, you can try the following steps:

  1. Make sure that the pins actually match (as in that analog/digital io and voltage supply pins for both boards are the same)
  2. comment out line 93 and 94 (those are the samd21 related adc settings) and try to compile again
  3. Check if adc resolution on the rp2040 is also 12 bit and if you can get the pwm to behave the same way (might be tricky).

But again this is not officially supported, if you get a version working with the 2040 feel free to create a pullrequest and we can add this as a separate firmware

guytanium commented 1 year ago

Oh wow. That’s embarrassing I bought the wrong microcontroller! Thanks for the fast reply. I’m sure I can find another use for my 2040, now to source a samd21 chip.