ADC conversion

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ADC conversion

3,350件の閲覧回数
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 返答(返信)

774件の閲覧回数
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 件の賞賛
返信

774件の閲覧回数
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 件の賞賛
返信