|
|
View previous topic :: View next topic |
Author |
Message |
KB Guest
|
PIC18F4431 read group ADC |
Posted: Mon Jun 02, 2008 3:47 am |
|
|
Helllo,
I try to read 2 channels (channel 0 and 1) using "group A and B are sampled simultaneously and converted sequentially" mode.
And read the result in a interrupt, but this seems not to be working. The only result i get is the value from one channel depends on what i set in the config "set_adc_channel()".
PIC: PIC18F4431
compiler : 4.057
code:
config adc,
setup_adc(DC_CLOCK_DIV_32|ADC_TAD_MUL_12|ADC_CONT_AB|ADC_WHEN_PPWM|ADC_INT_EVERY_OTHER);
set_adc_channel( 0 );
Interrupt:
#INT_AD
void ADCread ()
{
channel0= read_adc( ADC_READ_ONLY );
channel1 = read_adc( ADC_READ_ONLY );
}
i also try:
void ADCread ()
{
set_adc_channel( 0 );
channel0= read_adc( ADC_READ_ONLY );
set_adc_channel( 0 );
channel1 = read_adc( ADC_READ_ONLY );
}
But that also not working.
What could be the problem?
gr
KB |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 02, 2008 9:04 am |
|
|
What you are trying to do, is only partly supported by the CCS functions. Their setup, supports enabling the extra features on these chips, but the read_adc function, only returns the current values in the result registers, as for a normal unbuffered ADC. I'd suggest trying defining ADCON1, and changing the buffer address selection bits, between the reads. So something like:
Code: |
#byte ADCON1=0xFC1
ADCON1=ADCON1 & 0xFC;
channel0=read_adc(ADC_READ_ONLY);
ADCON1++;
channel1=read_adc(ADC_READ_ONLY);
|
No guarantees!. You may need to enable the FIFO as well (before starting the conversions), since there does not seem to be a setting for this in the CCS code.
This is the 'problem' of the CCS fuctions, when chips appear, with new abilities.
Best Wishes |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 02, 2008 9:11 am |
|
|
Note also, the comment in the .h file, about using four parameters to 'set_adc_channnel', for this chip. Looks like you use something like:
set_adc_channel(0,1,NULL,NULL);
Worth some experimenting.
Best Wishes |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|