Ttelmah
Joined: 11 Mar 2010 Posts: 19516
|
|
Posted: Tue Jun 09, 2015 1:50 am |
|
|
#byte ADCON1=getenv("SFR:ADCON1")
Then ADCON1 is a byte variable, that can be accessed like any other. Same syntax for ADCON0.
However, 'why'?.
Generally needing to access a register directly is a sign of not actually writing CCS code.
I repeat what I said in line 2 of my reply to your question about setting the clock:
"2) Don't. Let CCS handle the selections for you. For 99.9% of things you never need to touch a register in CCS."
The way to set the clock in CCS, is simply:
Code: |
setup_adc(ADC_CLOCK_DIV_32); //Choose division according to clock rate
|
The compiler knows which registers it has to access to set the ADC clock, and does so.
If you look in the data sheet for 'possible clock rates', and then look at the header file for your chip, you will see a 1:1 correspondence between the options offered, and the data sheet options.
Similarly with setup_adc_ports, and which pins can be selected, and which voltage references can be used. So to just select AN0, using the supply as Vref:
Code: |
setup_adc_ports(AN0);
|
However to use the same pin with external VrefH & VrefL:
Code: |
setup_adc_ports(AN0_VREF_VREF);
|
The defined names, will remind you in the future, what you were doing, while a number written to the ADCON registers _won't_. Come back in six months time, and try to work out what you were doing, and using the CCS functions will suddenly seem like having been a very good idea.
You have the CCS compiler, so _use_ it. |
|