|
|
View previous topic :: View next topic |
Author |
Message |
pilar
Joined: 30 Jan 2008 Posts: 197
|
ADC 12bits |
Posted: Mon Oct 19, 2009 9:33 am |
|
|
Hi, I'm trying to use the 12-bit ADC of 18F4458, the result I want to put in two registers, as I do to separate the ADC result into two bytes?
Code: | #include <18F4458.h>
#device adc=12
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#byte ADRESL = 0xFC3
#byte ADRESH = 0xFC4
//=================================
void main()
{
int16 value;
int8 Buffer_ADC[2];
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(0);
delay_us(15);
while(1)
{
value = read_adc();
Buffer_ADC[0] = valueL??; // MSB
Buffer_ADC[1] = valueH??; // LSB
//printf("%lu \n\r", value);
delay_ms(500);
}
} |
|
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Mon Oct 19, 2009 9:38 am |
|
|
Code: |
Buffer_ADC[0] = make8(value, 0);
Buffer_ADC[1] = make8(value, 1);
|
_________________ David |
|
|
pilar
Joined: 30 Jan 2008 Posts: 197
|
|
Posted: Tue Oct 20, 2009 7:31 am |
|
|
Thank you.. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|