View previous topic :: View next topic |
Author |
Message |
hanckmann
Joined: 16 Apr 2004 Posts: 9
|
OK |
Posted: Fri May 07, 2004 5:16 am |
|
|
Ok, now I changes some other stuff (I am not yet shure what the problem was) and it DOES WORK !!!
I am now testing what the problem really was. I will add it in this post later.
Thanks for all your help
Best regards,
Patrick |
|
|
hanckmann
Joined: 16 Apr 2004 Posts: 9
|
?????? |
Posted: Fri May 07, 2004 6:14 am |
|
|
Now I tried to find out what the real problem was. But i still do not have a clue....
This is the code I use now in the while(FOREVER) loop (see the source code listed before). I have enabled the interrupt now !!!!
Code: | while(FOREVER)
{
Setup_Adc_Ports(RA0_RA1_RA3_ANALOG);
Setup_Adc(ADC_CLOCK_DIV_8);
Enable_Interrupts(INT_AD);
SET_ADC_CHANNEL(0);
delay_us(40);
SetMux(0);
adc1= READ_ADC();
SET_ADC_CHANNEL(1);
delay_us(40);
SetMux(2);
adc2= READ_ADC();
lcd_clear();
printf(lcd_putc,"X1: %ld\nX2: %ld", adc1, adc2);
SETUP_PORT_A(NO_ANALOGS);
Set_Tris_A (SETPORTA);
} // end of while(FOREVER) |
Everything works now with the ADC, but if somebody has a clue about what was going wrng before I would like to know it !!!
Thanks again
Patrick |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri May 07, 2004 6:42 am |
|
|
It was probably a combination of more than one problem: Wrong oscillator fuse setting, wrong ADC clock setting, using the wrong ADC channel,... |
|
|
|