View previous topic :: View next topic |
Author |
Message |
Guest
|
Analog to digital conversion |
Posted: Tue Jan 16, 2007 8:05 am |
|
|
I am trying to read the analog voltage on pin A1. Using the development board, I modified example 7 from the book
setup_adc_ports( RA0_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
to use ( RA1_ANALOG ) instead, but the compiler gave me the error "Undefined identifier RA1_ANALOG". What am I doing wrong? |
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 16, 2007 8:14 am |
|
|
First, what chip?.
Now look at the data sheet for the chip. What 'patterns' of analog inputs a supported?. Gnerally, on most chips, you cannot have RA1, as analog on it's own. The patterns normally run something like:
AN0
AN0+AN1+AN3
etc.
Hence there is no 'RA1_ANALOG' definition, since the chip does not support just having this pin as an analog input....
Best Wishes |
|
|
Guest
|
|
Posted: Tue Jan 16, 2007 8:25 am |
|
|
Thanks for the quick reply!
Its the PIC18F452. I've got the data sheet pdf in front of me, looking at section 17 (A-D Conversion) I haven't found what combinations are allowed yet, but the one you suggested seems to work OK. Thanks :-) |
|
|
jfk1965
Joined: 21 Oct 2003 Posts: 58
|
|
Posted: Tue Jan 16, 2007 8:40 am |
|
|
Look in the PICC/ devices folder and find the 18F452.h file and scroll down to the A/D section you will see all the valid options for that chip.
JFK |
|
|
Guest
|
|
Posted: Tue Jan 16, 2007 8:46 am |
|
|
Ah yes, there they all are - loads of options.
Thanks! |
|
|
|