Ram Prasadh
Member level 2
- Joined
- Feb 16, 2011
- Messages
- 51
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 1,725
Hi friends,
I am using adc module in pic18f4550. I just gave a dc signal to the module and varied it with a pot. My ADRES register shows some value,but that is not the one I am expecting.I am not knownig where I am going wrong. I ave just copied my code below.
suppose if I set 5v dc as my input , I am expecting the value 3FF(10 bit value) on the ADRES register. I am not getting it. It displays some other value.Please help me with what i have missed out.will provide further information if something is left out.
Regards,
Ram
I am using adc module in pic18f4550. I just gave a dc signal to the module and varied it with a pot. My ADRES register shows some value,but that is not the one I am expecting.I am not knownig where I am going wrong. I ave just copied my code below.
Code:
#include<htc.h>
void interrupt isr(void);
void main()
{
TRISA = 0XFF; TRISD = 0X00;
PORTD = 0X00; PORTA = 0X00;
ADCON0 = 0x09; ADCON1 = 0x0E; // Channel AN0 selected
ADCON2 = 0X3E;
T1CON = 0X00;
PEIE = 1; TMR1IE = 1; GIE = 1;
TMR1H=0XFF; TMR1L=0XF7; TMR1IF = 0;
TMR1ON = 1;
while(1);
}
void interrupt isr(void)
{
TMR1IF = 0;
GO = 1;
while(ADIF == 0);
ADIF = 0;
TMR1H=0XEF;
TMR1L=0XE5;
}
suppose if I set 5v dc as my input , I am expecting the value 3FF(10 bit value) on the ADRES register. I am not getting it. It displays some other value.Please help me with what i have missed out.will provide further information if something is left out.
Regards,
Ram
Last edited by a moderator: