setup_adc_ports(sAN1); //|VSS_VDD); // setup port RA1/AN1 as an analog
////setup_adc(ADC_CLOCK_INTERNAL); //|ADC_TAD_MUL_0);
set_adc_channel(1); // setup channel 8 for battery reading
adc_value = read_adc();
setup_adc_ports(NO_ANALOGS|VSS_VDD); // set back the ports in digital mode
setup_adc(ADC_OFF);
now whenever i execute this routine my external interrupt 0 become disabled. i check and tested a code and i found out "setup_adc(ADC_OFF)" causing interrupt 0 not to work.
if i use "setup_adc(ADC_CLOCK_INTERNAL)" then interrupt works.
my external interrupt routine is:
disable_interrupts(INT_EXT); //! don't reenable in ISR
clear_interrupt(INT_EXT);
//! timer 0 setup for debouncing time
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
clear_interrupt(INT_RTCC); //! enable debouncing timer0 interrupt
enable_interrupts(INT_RTCC);
set_timer0(TIMERVALUE);
i am enabling interrupt in timer routine.
regards:
nehal _________________ nehal
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Mon Jan 12, 2009 5:51 pm
You need to setup the ADC ports before you read the ADC.
The ADC needs to be enabled before you read it.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum