ADC conversion

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ADC conversion

3,338 次查看
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.
标签 (1)
0 项奖励
回复
2 回复数

762 次查看
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 项奖励
回复

762 次查看
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 项奖励
回复