tabemann / zeptoforth

A not-so-small Forth for Cortex-M

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

adc-pin reports "invalid ADC" with default-adc

twillis-prog opened this issue · comments

Found ads.fs adc-pin ( adc pin -- ) still had the pin on TOS when validate-adc executed.
Made to work by adding a 'drop" prior to validate-adc. When swap was tried, left pin on TOS.

\ Set a pin to be an ADC pin ( Modified )
: adc-pin ( adc pin -- )
dup pin-internal::validate-pin
dup 26 >= swap 29 <= and averts x-pin-has-no-adc-chan
drop \ <<<<<<<<<<<<<< added because the pin was on TOS, causing validate-adc to fail.
validate-adc
;

Yeah that is a bug. Actually, if you are targeting the RP2040, don't even use adc-pin because it is completely unnecessary. It is there only for compatibility with the STM32 API's sake, and I didn't catch the bug in my testing because I never used adc-pin on the RP2040.

My error! All is OK with adc.fs