Thanks again Henrik,
This works pretty good now. I would still like to get rid of the sound command and replace it with a steady HPWM signal eventually, but this will get me by for now and it doesn't look like the 10F222 even has PWM capability.
Jim
Code:
@ __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_ON & _IOFSCS_8MHZ
DEFINE OSC 8
TRISIO = %00111101
ADCON0 = %01000001 ' GPIO 0 = Analog, ADC Enabled
ANA_IN VAR GPIO.0 ' GPIO0/ANA0/PDAT
SPK VAR GPIO.1 ' GPIO1/ANA1/PCLK
Trigger VAR GPIO.2 ' GPIO2/T0CKI
' VAR GPIO.4 ' GPIO3/MCLR/VPP
Tone VAR byte
GO_DONE VAR ADCON0.1 ' Alias to GO/DONE bit for ADC
Main:
GO_DONE = 1 ' Start the conversion
WHILE GO_DONE : WEND ' Wait for it to complete.
Tone = ADRES
if Trigger then
Sound SPK,[Tone / 4 + 50, 1]
endif
Goto Main
End

Originally Posted by
HenrikOlsson
I have never used a 10F part before but looking at the datasheet that has got to be the easiest ADC there is to run. No Clock source selection, no left/right justification, no sample time configuration, nothing, three lines of code pretty much.
Code:
GO_DONE VAR ADCON0.1 ' Alias to GO/DONE bit for ADC
ADCON0 = %01000001 ' GPIO 0 = Analog, Channel 0 connected to ADC, ADC Enabled
GO_DONE = 1 ' Start the conversion
WHILE GO_DONE : WEND ' Wait for it to complete.
' Result is now availabe in ADRES.
Of course, not having used one before, may mean I'm missing something but it really looks like there's nothing more to in than that. If you can setup the CCP module manually you can figure out how to operate this ADC :-)
/Henrik.
Bookmarks