Sorry. It's hard to "guess" how you're configuring things if you don't show it in your code.
I'm sure this isn't what the rest of your own application is doing, but it works fine with the
pause 50 in there;
Code:
@ DEVICE HS_OSC, WDT_ON, LVP_OFF, PROTECT_OFF
DEFINE OSC 20
SYMBOL AD_Progress = ADCON0.2
SYMBOL ADON = ADCON0.0
SYMBOL LED = PORTB.0
Sound_Level VAR WORD
TRISA.0 = 1 ' A/D input
PORTB.0 = 1 ' LED on at boot
TRISB.0 = 0 ' LED output
ADCON0 = 128 ' A/D clock Fosc/32, RA0/AN0, A/D disabled
ANSEL = 1 ' RA0 analog
ADCON1.7 = 1 ' right justify for 10-bit
Main:
ADON = 1 ' turn on A/D module
PAUSE 50 ' wait
AD_Progress = 1 ' start conversion
WHILE AD_Progress = 1 : WEND
Sound_Level.lowbyte = ADRESL
Sound_Level.highbyte = ADRESH
LED = LED ^ 1 ' toggle LED for visual
GOTO Main
END
I left the WDT enabled just to be sure PBP was handling it during the pause periods.
Bookmarks