Can the ADC be used in non-smartpin mode?
rogloh
Posts: 5,808
During some MicroPython work I was reading through the P2 documentation and experimenting around with pins in different modes. It appears from this statement that the ADC may be enabled when OUT=1, implying you can somehow use it in this non-smartpin mode:
But if so, how do you read it? I've tried setting :
WRPIN to $148000 which enables the 990 ohm DAC at its midpoint, and
DRVH = 1<<Pin to enable the pin's OUT bit
I do see the pin's output is at the midway voltage level of 1.66V, but I don't see any activity with either RDPIN or the input bit of this pin, which both remain stuck at 0. Isn't the ADC meant to accumulate/report samples when OUT=1 or does the ADC do nothing unless the pin is in a real Smart pin mode (ie. MMMMM<>0)? How is it used here with MMMMM=0?
Update: Never mind, I think I got it working after trying the ADC mode without DAC. Somehow the DRVH operation in ADC+DAC mode didn't take effect properly the first time I tried it, I've repeated this a few times since and it seems to be toggling the read back pin input value for both ADC, and ADC+DAC modes. It appears it's just the raw bitstream you get back directly via the input pin and you'd have to average it's value over time yourself to use it, or otherwise use a Smartpin mode to accumulate highs to do it for you.
for smart pin mode off (%MMMMM = %00000): DIR enables output for non-DAC_MODE: 0x = OUT drives output 1x = OTHER drives output for DAC_MODE: 00 = OUT enables ADC, P[7:0] sets DAC level 01 = OUT enables ADC, P[3:0] selects cog DAC channel 10 = OUT drives BIT_DAC 11 = OTHER drives BIT_DAC
But if so, how do you read it? I've tried setting :
WRPIN to $148000 which enables the 990 ohm DAC at its midpoint, and
DRVH = 1<<Pin to enable the pin's OUT bit
I do see the pin's output is at the midway voltage level of 1.66V, but I don't see any activity with either RDPIN or the input bit of this pin, which both remain stuck at 0. Isn't the ADC meant to accumulate/report samples when OUT=1 or does the ADC do nothing unless the pin is in a real Smart pin mode (ie. MMMMM<>0)? How is it used here with MMMMM=0?
Update: Never mind, I think I got it working after trying the ADC mode without DAC. Somehow the DRVH operation in ADC+DAC mode didn't take effect properly the first time I tried it, I've repeated this a few times since and it seems to be toggling the read back pin input value for both ADC, and ADC+DAC modes. It appears it's just the raw bitstream you get back directly via the input pin and you'd have to average it's value over time yourself to use it, or otherwise use a Smartpin mode to accumulate highs to do it for you.
Comments
Andy