ADC conversion

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC conversion

3,344 Views
ppcco
Contributor I
Hi, I'm sensing light with a photoresistor, the analog input is received via QB8 A/D converter in 10 bit, my program is wrote in C (CW) the question is, how can convert the 10 bit value into decimal value?, the binary value is stored in two different registers, 8 LSB in an register and two MSB in another, someone have a routine write in C to implement? Thanks.
Labels (1)
0 Kudos
Reply
2 Replies

768 Views
FWFan
Contributor III
Hi ppcco,
 
I'm trying to capture my filter signal with my 8 bit QE128 board too.  Do you think I can see your code for your ac signal capture?
 
Thank you,
FWFan
0 Kudos
Reply

768 Views
alex_spotw
Contributor III
Hi:

If you're using Processor Expert, you can use one of the methods provided by the ATD Bean to read the value as 16 bits.

If you're not using PE, you can use code like:
(From PE)
/* 16-bit register (big endian) */
typedef union {
word w;
struct {
byte high,low;
} b;
} TWREG;


word Read_Sample(void)
{
TWREG Sample

Sample.b.high = ATD1RH;
Sample.b.low = ATD1RL;
return Sample.w; // Return as word (16 bit)
}


Regards,

Alex
0 Kudos
Reply