MAX1233/MAX1234觸摸屏控制器入門
DEMO1234 Command
SPI data in
T W DD FF
0x000b 0x00ff
T W DD 00
0x000b 0x0000
T W DD 80
0x000b 0x0080
T W DC 8000
0x0042 0x8000
T W DC 0
0x0042 0x0000
2.2) 選擇ADC基準(zhǔn)電源模式
ADC需要一個(gè)基準(zhǔn)電壓。對(duì)于典型的嵌入式系統(tǒng)工作,默認(rèn)設(shè)置是fine。在自動(dòng)上電模式(ADC3210 = 0000,RES10 = 00)下,MAX1233/MAX1234提供自己的內(nèi)部基準(zhǔn)電壓。在每次測(cè)量之前,內(nèi)部基準(zhǔn)自動(dòng)上電,測(cè)量完成后關(guān)斷。對(duì)于第一次診斷,保持上電模式(ADC3210 = 0000,RES10 = 01)支持使用手持式DVM對(duì)基準(zhǔn)電壓進(jìn)行外部驗(yàn)證。
ADC掃描選擇位設(shè)置為0000,寫入ADC控制寄存器(0x40),來設(shè)置ADC基準(zhǔn)電源模式。RES1/RES0位選擇基準(zhǔn)電源模式,基準(zhǔn)控制位RFV選擇內(nèi)部1.0V或者2.5V基準(zhǔn)(請(qǐng)參考MAX1233/MAX1234數(shù)據(jù)資料的表13)。
ADC控制字:x x 0 0 0 0 RES1 RES0 x x x x x x x RFV
表4. 內(nèi)部基準(zhǔn)命令
DEMO1234 Command | Action | SPI data in | Verification |
T W AC 0100 | Internal 1V reference always powered; write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 0 | 0x0040 0x0100 | Voltage at pin 12 REF is between 0.98V and 1.02V |
T W AC 0101 | Internal 2.5V reference always powered; write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 1 | 0x0040 0x0101 | Voltage at pin 12 REF is between 2.47V and 2.53V |
T W AC 0001 | Internal 2.5V reference powered when needed; write ADC control word with ADC3210 = 0000, RES10 = 00, RFV = 1 | 0x0040 0x0001 | Voltage at pin 12 REF will be powered only briefly as necessary |
表5. 外部基準(zhǔn)命令
DEMO1234 Command | Action | SPI data in |
T W AC 0300 | External reference must be provided; ADC_control_wr_demand_scan:(write)demand scan ADC_control_AD0000:configure reference ADC_control_RES11:external reference | 0x0040 0x0300 |
2.3) 測(cè)量外部電壓輸入AUX1和AUX2
表6. ADC測(cè)量命令序列DEMO1234 Command | Action (Triggered by A/D3210 Bits) | SPI data in |
T M8 | Measure AUX1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2301 0x8007 0x0000 |
T W AC 2301 | Trigger ADC scan of AUX1; ADC control word 0x2301 means: ADC_control_wr_demand_scan ADC_control_AD1000 /* measure AUX1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ | 0x0040 0x2301 |
T R A1 | Read AUX1 result AUX1_code | 0x8007 0x0000 |
T M9 | Measure AUX2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2701 0x8008 0x0000 |
2.4) 將AUX1和AUX2轉(zhuǎn)換結(jié)果譯為物理值
下面的C/C++偽代碼片斷總結(jié)了DEMO1234程序是怎樣解釋AUX1和AUX2轉(zhuǎn)換結(jié)果的。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution *//* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. *//* AUX1_code is the 16-bit result read by SPI command 0x8007 */double AUX1_Voltage = (AUX1_code * ADC_fullscale_voltage) / num_codes;/* AUX2_code is the 16-bit result read by SPI command 0x8008 */double AUX2_Voltage = (AUX2_code * ADC_fullscale_voltage) / num_codes;
2.5) 測(cè)量外部電壓輸入BAT1和BAT2
表7. ADC測(cè)量命令序列DEMO1234 Command | Action (Triggered by A/D3210 Bits) | SPI data in |
T M6 | Measure BAT1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x1b01 0x8005 0x0000 |
T W AC 1b01 | Trigger ADC scan of BAT1; ADC control word 0x1b01 means: ADC_control_wr_demand_scan ADC_control_AD0110 /* measure BAT1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ | 0x0040 0x1b01 |
T R B1 | Read BAT1 result BAT1_code | 0x8005 0x0000 |
T W AC 1b21 | Trigger ADC scan of BAT1; ADC control word 0x1b21 means: ADC_control_wr_demand_scan ADC_control_AD0110 /* measure BAT1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR10 /* conversion rate 10μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ | 0x0040 0x1b21 |
T R B1 | Read BAT1 result BAT1_code | 0x8005 0x0000 |
T M7 | Measure BAT2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x1f01 0x8006 0x0000 |
2.6) 將BAT1和BAT2轉(zhuǎn)換結(jié)果譯為物理值
下面的C/C++偽代碼片斷總結(jié)了DEMO1234程序是怎樣解釋BAT1和BAT2轉(zhuǎn)換結(jié)果的。注意:通過一個(gè)4:1輸入分配器來測(cè)量BAT1和BAT2。/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution *//* Voltage that corresponds to the full-scale ADC code; may be internal 1V or 2.5V ref, or ext ref. */double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V. RFV=0: VREF=1.0V. *//* Note: BAT1 and BAT2 measure through a 4:1 input divider. *//* BAT1_code is the 16-bit result read by SPI command 0x8005 */double BAT1_Voltage = 4 * (BAT1_code * ADC_fullscale_voltage) / num_codes;/* BAT2_code is the 16-bit result read by SPI command 0x8006 */double BAT2_Voltage = 4 * (BAT2_code * ADC_fullscale_voltage) / num_codes;
2.7) 測(cè)量?jī)?nèi)部溫度TEMP1和TEMP2
表8. ADC測(cè)量命令序列DEMO1234 Command | Action (Triggered by A/D3210 Bits) | SPI data in |
T MA | Measure TEMP1 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x2b01 0x8009 0x0000 |
T W AC 2b01 | Trigger ADC scan of TEMP1; ADC control word 0x2b01 means: ADC_control_wr_demand_scan ADC_control_ AD1010 /* measure TEMP1 */ ADC_control_RES11 /* 12-bit resolution */ ADC_control_AVG00 /* no averaging */ ADC_control_CNR00 /* conversion rate 3.5μs */ ADC_control_RFV /* RFV=1: VREF=2.5V */ | 0x0040 0x2b01 |
T R T1 | Read TEMP1 result TEMP1 _code | 0x8009 0x0000 |
T MC | Measure TEMP1, TEMP2 with 12-bit resolution and 3.5μs conversion rate | 0x0040 0x3301 0x8009 0x0000 0x800a 0x0000 |
T W AC 3301 | Trigger ADC scan of TEMP1 and TEMP2; ADC control word 0x3301 means: ADC_control_wr_demand_scan ADC_control_ AD 相關(guān)推薦技術(shù)專區(qū)
|
評(píng)論