That's odd. It works for me without getting stuck.
I modified your version to include 3 LED's in the last section of each channel read routine,
and all 3 LED's blink right along.
It doesn't appear to be getting getting stuck at any point.
Code:
@ DEVICE HS_OSC, WDT_ON, LVP_OFF, PROTECT_OFF
DEFINE OSC 20
SYMBOL AD_Progress = ADCON0.2
SYMBOL ADON = ADCON0.0
SYMBOL LED1 = PORTB.0
SYMBOL LED2 = PORTB.1
SYMBOL LED3 = PORTB.2
Sound_Level VAR WORD
Negative_Voltage VAR WORD
Positive_Voltage VAR WORD
TRISA.0 = 1 ' A/D input
PORTB = %00000111 ' LED's on at boot
TRISB = 0 ' LED outputs
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
LED1 = LED1 ^ 1 ' toggle LED for visual
'retrieve negative level
ADCON0.5 = 0
ADCON0.4 = 0
ADCON0.3 = 1
PAUSE 50
AD_Progress = 1
WHILE AD_Progress = 1: WEND
Negative_Voltage.lowbyte = ADRESL
Negative_Voltage.highbyte = ADRESH
LED2 = LED2 ^ 1 ' toggle LED for visual
'retrieve positieve level
ADCON0.5 = 0
ADCON0.4 = 1
ADCON0.3 = 0
PAUSE 50
AD_Progress = 1
WHILE AD_Progress = 1: WEND
Positive_Voltage.lowbyte = ADRESL
Positive_Voltage.highbyte = ADRESH
LED3 = LED3 ^ 1 ' toggle LED for visual
GOTO Main
END
Are you reading 0-5 VDC voltage levels?
Bookmarks