richardlaishram
Member level 4
- Joined
- Jan 6, 2013
- Messages
- 77
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Planet Earth
- Activity points
- 1,804
I'm using the header file <htc.h> for my PIC16F716 ADC project using PIC16
Following are the codes after referring the datasheet and a sample code for PIC16F877A.
when building the project, I'm getting the error undefined identifier "ADRES"
I've got a code with PIC16F877A for an ADC Project, I've tried it and it's working fine in Proteus.
Here's my query:
1. The ADC result registers for PIC16F877A (ADRESH and ADRESL - 10bit) is not showing any error whereas PIC16F716 (ADRES - 8bit) is not recognized by <htc.h>
2. Can I use GO_nDONE to check for the completion of AD Conversion in PIC16F716 also?
Thanks in Advance.
Following are the codes after referring the datasheet and a sample code for PIC16F877A.
Code:
void InitADC(void)
{
TRISA0 = 0x01; // PortA Pin0 configured as input
ADCON1 = 0x00; // PortA configured as Analog input with Vref as Vdd
ADCON0 = 0x41; // ADC Enabled
}
unsigned int ADCValue0(void)
{
ADCON0 &= 0x45; // Start AD Conversion
ADCON0 |= 0x40; // Conversion Cycle in Progress
__delay_ms(10);
while(ADCON0 |= 0x40); // Wait for AD conversion to Complete
return ADRES; // ADC result stored
}
when building the project, I'm getting the error undefined identifier "ADRES"
I've got a code with PIC16F877A for an ADC Project, I've tried it and it's working fine in Proteus.
Code:
void InitADC(void)
{
ADCON1 = 0x80;
TRISA = 0x2F;
ADCON0 = 0x81;
}
unsigned int ADCValue(void)
{
ADCON0 &= 0x87;
ADCON0 |= 0x08;
__delay_ms(10);
GO_nDONE = 1;
while(GO_nDONE);
return ((ADRESH<<8)+ADRESL);
}
Here's my query:
1. The ADC result registers for PIC16F877A (ADRESH and ADRESL - 10bit) is not showing any error whereas PIC16F716 (ADRES - 8bit) is not recognized by <htc.h>
2. Can I use GO_nDONE to check for the completion of AD Conversion in PIC16F716 also?
Thanks in Advance.