개요: 이 애플리케이션 노트에서는 MAX1233/MAX1234 터치스크린 컨트롤러의 기능을 사용하는 방법에 대해 설명한다. 간편한 콘솔 메뉴 시스템을 통해 MAX1233/MAX1234 소자 레지스터에 직접적인 로우 레벨 액세스가 가능하다. 각 레지스터의 읽기 또는 쓰기 동작은 32 SPI™ 클록 사이클을 사용한다. 소프트웨어는 각 레지스터에 짧은 코드명을 사용한다. 이 소프트웨어는 MAX1234 EV 킷 (EV Kit) 보드 및 MINIQUSB+ 명령 모듈과 함께 사용할 때 로우 레벨 제어를 극대화할 수 있다. 포함된 압축 파일에는 전체 소스 코드가 제공된다.
MAX1233 동작은 5.0V 대신 3.3V 전원으로 동작하는 점만 제외하면 MAX1234 동작과 동일하다. MAX1234 EV 킷 보드의 점퍼 JU1은 3.3V에서 MAX1234를 동작시켜 MAX1233을 에뮬레이트한다.
참고: 서픽스 "-bar"(CS-bar 등)는 CS, PENIRQ, KEYIRQ, BUSY 핀의 액티브 로우 기능을 나타낸다.
Maxim MINIQUSB+ (USB A-B 케이블 및 MINIQUSB-X+ 익스팬더 보드 포함)
USB 기능이 있는 Windows® 2000/XP PC
4-Wire 저항 터치스크린 (대체 PDA 디지타이저/글래스탑 등)
옵션: DAC 출력 전압 측정을 위한 DMM
옵션: AUX 및 BAT 입력을 구동하는 전압 소스
옵션: PENIRQ-bar 및 KEYIRQ-bar 핀의 자동 스캔 인터럽트 펄스를 관찰하는 오실로스코프
1.2) MINIQUSB+ 펌웨어 업데이트 안내
MAX1233/MAX1234는 처음 변환을 마치기 전에 CS-bar 핀을 하이로 디어서트해야 한다. 그렇지 않을 경우 ADC는 변환 결과를 저장할 수 없다. 이 애플리케이션 노트를 사용하기 전에 표준 MINIQUSB+ 모듈 펌웨어를 업데이트하여 SPI 인터페이스의 CS-bar 핀을 32nd SCLK의 1.4µs 내에서 디어서트할 수 있도록 해야 한다. 2MHz에서 32비트 auto-CS-bar 제어 모드는 CS-bar를 21.70µs 동안 로우로 유지한다. MAXQ2000 마이크로컨트롤러의 비휘발성 플래시 메모리에 있는 MINIQUSB+ 펌웨어는 한번만 업데이트하면 된다. 이 새로운 펌웨어는 표준 01.05.39 베이스라인 펌웨어와 역 호환된다.
펌웨어 업그레이드는 SPI 인터페이스의 CS-bar 타이밍을 향상시키는 것 외에도, 인터럽트 구동 펄스 누산기를 포함하고 있어 MAX1233/MAX1234가 자동 스캔 모드로 구성되어 있을 때, PENIRQ-bar 및 KEYIRQ-bar에서 자체 소거 (self-clearing) 인터럽트 펄스가 발생되었는지 확인할 수 있다. PENIRQ-bar의 지속 시간은 구성된 ADC 변환 레이트에 의해 결정되며, KEYIRQ-bar의 지속 시간은 구성된 스위치 디바운스 시간에 의해 결정된다.
표 1과 같이 MAX1234 EV 킷 커넥터 J1에서 MINIQUSB-X+ 익스팬더 보드(MINIQUSB+에 포함)로 와이어를 연결한다. MAX1234 EV 킷에 와이어를 납땜하는 대신 3M® 인트라 커넥터 922576-40을 J1에 꽂을 수 있으므로 편리하게 연결할 수 있다. 단자 블록 TB1은 연결하지 않은 채로 둔다.
표 1. MAX1234 EV 킷과 MINIQUSB+ 보드 셋 연결
MAX1234 Signal
MAX1234 EV Kit
MINIQUSB-X+
MINIQUSB Signal
GND
J1-1
H2-8
GND
VCC
J1-7
H2-1
3.3V supply from MINIQUSB+
BUSY-Bar
J1-27
H2-7
GPIO-K7 (MAXQ2000-INT2)
PENIRQ-Bar
J1-29
H1-3
GPIO-K6 (MAXQ2000-INT1)
KEYIRQ-Bar
J1-31
H1-8
GPIO-K5 (MAXQ2000-INT0)
DOUT
J1-35*
H2-2
MISO (SPI master in, slave out)
DIN
J1-36*
H2-5
MOSI (SPI master out, slave in)
SCLK
J1-37*
H2-3
SCLK (SPI clock)
CS-Bar
J1-38
H2-4
CS-bar (SPI chip select)
USB+5V
J1-5
J4-7
USB+5V supply from PC
* 참고: MAX1234 EV 킷의 디지털 입력은 커넥터 J1을 통해 구동되어야 하며, U1 주변의 테스트 지점으로 직접 구동되어서는 안 된다. MAX1234 EV 킷의 디지털 신호를 구동하려면 온 보드 MAX1841 레벨 변환기를 사용해야 한다.
MINIQUSB+를 익스팬더 보드의 상단에 꽂는다.
MINIQUSB+를 PC의 USB 포트에 연결한다. MINIQUSB+를 PC에 처음으로 연결할 때에는 플러그 앤 플레이 마법사가 나타난다. Windows에서 디바이스 드라이버(제공된 압축 파일에 포함)의 설치 위치로 간다.
펌웨어 업데이트 배치 파일 FWUPDATE.BAT를 실행하여 MINIQUSB+ 펌웨어를 업데이트한다.
펌웨어 업데이트가 완료되면, MINIQUSB+를 PC의 USB 포트에서 분리한다.
그림 1. 하드웨어 구성 (터치스크린은 이후 단계에서 연결한다.)
림 2. 3M 인트라 커넥터를 사용하여 MINIQUSB+와 MAX1234 EV 킷을 연결한 시스템 사진
1.4) 절차
MAX1234 EV 킷 점퍼 JU1을 "MAX1234" 위치로 설정한다.
MINIQUSB+를 PC의 USB 포트에 연결한다. DACOUT 전압이 미드 스케일(2.2V)인지 확인한다.
DEMO1234.EXE 프로그램을 실행한다. 화면에 콘솔이 나타난다.
콘솔에 다음과 같은 일련의 명령을 입력한다.
표 2. 연결 및 명령 시퀀스 확인
DEMO1234 Command*
Expected Program Output
SPI data in
Verification**
C
Board connected.
Got board banner: Maxim MINIQUSB V01.05.41 >
Firmware version is OK.
(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...
T W DD FF
Write_Register(regAddr=0x000b wr_DAC_data ,
data=0x00ff
{(no bits defined for this register)}) result = 1
0x000b 0x00ff
DACOUT = full-scale (4.5V)
T R DD
Read_Register(regAddr=0x800b wr_DAC_data ) result = 1,
buffer = 0x00ff = 255
{(no bits defined for this register)}
0x800b 0x0000
Data buffer = 0x00ff
T W DD 80
Write_Register(regAddr=0x000b wr_DAC_data ,
data=0x0080
{(no bits defined for this register)}) result = 1
0x000b 0x0080
DACOUT = mid-scale (2.2V)
T R DD
Read_Register(regAddr=0x800b wr_DAC_data ) result = 1,
buffer = 0x0080 = 128
{(no bits defined for this register)}
0x800b 0x0000
data buffer = 0x0080
* DEMO1234 Command 칼럼에는 DEMO1234.exe 프로그램에 입력할 명령이 나와 있다.
** Verification 칼럼에는 명령이 수행되었는지 확인하기 위해 수행할 수 있는 모든 물리적 테스트가 나와 있다.
1.5) SPI data in 예제 형식 설명
SPI data in 칼럼에는 MAX1233/MAX1234 DIN 핀으로 구동되는 16진수, 최상위 바이트의 SPI 데이터가 나와 있다. 예를 들어, 시퀀스 0x000b 0x00ff의 SPI 데이터는 DIN으로 클록 인되는 32비트 시퀀스가 0000 0000 0000 1011 0000 0000 1111 1111임을 의미한다. 첫 번째 비트는 레지스터 쓰기 동작을 위한 0과 레지스터 읽기 동작을 위한 1이다.
레지스터 쓰기 동작은 0000 0000 a7-a0 d15-d0 형식의 32비트 SPI 전송이다.
레지스터 읽기 동작은 1000 0000 a7-a0 0000 0000 형식의 32비트 SPI 전송으로, 수신되는 데이터는 최종 16비트 동안 DOUT으로부터 클록 인된다.
2) 아날로그 I/O 예제
다음 예제는 DEMO1234.EXE 프로그램을 사용하여 DAC 출력을 제어하고 기준 전압을 구성하는 방법, 그리고 AUX1/AUX2/BAT1/BAT2 전압 입력 및 내부 MAX1234 온도를 측정하는 방법을 보여준다.
2.1) DAC 출력 전압 제어하기
DAC는 2개의 레지스터에 의해 제어된다. 출력 전압을 설정하려면 DAC 데이터 레지스터를 쓴다. DAC를 셧다운 하거나 전원을 인가하려면 DAC 제어 레지스터를 쓴다. 디폴트 파워 온 상태는 DAC에 전원이 인가되고 DAC 출력이 미드 스케일인 상태이다. DAC 풀 스케일 전압은 일반적으로 AVDD의 90%이다(최소 85%, 최대 95%).
AVDD = 3.3V ±5%일 때, DACOUT 풀 스케일 범위는 2.65V ~ 3.27V로, 보통 2.96V이다.
AVDD = 5.0V ±5%일 때, DACOUT 풀 스케일 범위는 4.02V ~ 4.97V로, 보통 4.48V이다.
표 3. DAC 출력 명령
DEMO1234 Command
Action
SPI data in
MAX1233 (3.3V)
MAX1234 (5.0V)
T W DD FF
DACOUT = full-scale
0x000b 0x00ff
DACOUT = 2.96V
DACOUT = 4.48V
T W DD 00
DACOUT = 0V
0x000b 0x0000
DACOUT = 0.0V
DACOUT = 0.0V
T W DD 80
DACOUT = mid-scale
0x000b 0x0080
DACOUT = 1.485V
DACOUT = 2.25V
T W DC 8000
Disable DAC
0x0042 0x8000
DACOUT = 0.0V
DACOUT = 0.0V
T W DC 0
Enable DAC
0x0042 0x0000
DACOUT = 1.485V
DACOUT = 2.25V
2.2) ADC 기준 전력 모드 선택하기
ADC는 기준 전압을 필요로 한다. 일반적인 임베디드 시스템 동작은 기본 설정으로 충분하다. 자동 파워 업 모드(ADC3210 = 0000, RES10 = 00)에서 MAX1233/MAX1234는 자체적인 내부 기준 전압을 제공한다. 이 내부 기준 전압은 매번 측정 전에 자동으로 파워 업하고, 측정이 완료되면 파워 다운한다.
초기 진단을 위해 상시 파워 업 (always-powered-up) 모드(ADC3210 = 0000, RES10 = 01)에서는 휴대용 DVM을 사용하여 기준 전압을 외부에서 확인할 수 있다.
ADC 기준 전력 모드는 ADC 제어 레지스터(0x40)에 0000으로 설정된 ADC 스캔 선택 비트를 써 설정한다. RES1/RES0 비트는 기준 전력 모드를 선택하고, 기준 제어 비트 RFV는 내부 1.0V 또는 2.5V 기준 전압을 선택한다(MAX1233/MAX1234 데이터 시트의 표 13을 참조한다).
ADC 제어 워드: x x 0 0 0 0 RES1 RES0 x x x x x x x RFV
표 4. 내부 기준 명령
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. 외부 기준 명령
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) 외부 전압 입력 AUX1, AUX2 측정하기
표 6. ADC 측정 명령 시퀀스
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 변환 결과를 물리적 값으로 변환하기
다음의 C/C++ 수도코드 조각(snippet)은 AUX1과 AUX2 변환 결과가 DEMO1234 프로그램에 의해 어떻게 해석되는지를 보여준다.
/* 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) 외부 전압 입력 BAT1, BAT2 측정하기
표 7. ADC 측정 명령 시퀀스
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 변환 결과를 물리적 값으로 변환하기
다음의 C/C++ 수도코드 조각은 BAT1 및 BAT2 변환 결과가 DEMO1234 프로그램에 의해 어떻게 해석되는지를 보여준다. 참고: BAT1 및 BAT2는 4:1 입력 분배기를 통해 측정한다.
/* 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) 내부 온도 TEMP1, TEMP2 측정하기
표 8. ADC 측정 명령 시퀀스
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_ AD1100 /* measure TEMP1,TEMP2 */
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 0x3301
T R T1
Read TEMP1 result TEMP1 _code
0x8009 0x0000
T R T2
Read TEMP2 result TEMP2 _code
0x800a 0x0000
2.8) TEMP1 변환 결과를 물리적 값으로 변환하기
다음의 C/C++ 수도코드 조각은 TEMP1 변환 결과가 DEMO1234 프로그램에 의해 어떻게 해석되는지를 보여준다.
/* 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. */
/* TEMP1_code is the 16-bit result read by SPI command 0x8009 */
double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_codes;
/* Calibration values */
const double Temp1V_Room = 0.590; // temp1 voltage at room temperature 25C
const double Temp1K_Room = 298.15; // Room temperature Kelvins (298.15K=25C)
const double Temp1V_Per_K = -0.002; // TempCo -2mV per degree C
/* Convert to absolute temperature */
double Kelvin = (TEMP1_Voltage - Temp1V_Room) / Temp1V_Per_K + Temp1K_Room;
/* Optional conversion to commonly used temperature units */
double Centigrade = Kelvin - 273.15;
double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.9) TEMP1 및 TEMP2 변환 결과를 물리적 값으로 변환하기
다음의 C/C++ 수도코드 조각은 TEMP1 및 TEMP2 변환 결과가 DEMO1234 프로그램에 의해 어떻게 해석되는지를 보여준다. TEMP2는 TEMP1과 비교될 때에만 의미가 있다.
/* 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. */
/* TEMP1_code is the 16-bit result read by SPI command 0x8009 */
double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_codes;
/* TEMP2_code is the 16-bit result read by SPI command 0x800a */
double TEMP2_Voltage = (TEMP2_code * ADC_fullscale_voltage) / num_codes;
/* Calibration values */
const double K_Per_Temp21_Delta_V = 2680.0; // nominal 2680 5/27/2002
/* Convert to absolute temperature */
double Kelvin = (TEMP2_Voltage - TEMP1_Voltage) * K_Per_Temp21_Delta_V;
/* Optional conversion to commonly used temperature units */
double Centigrade = Kelvin - 273.15;
double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.10) 외부 전압 입력 AUX1, AUX2, BAT1, BAT2 및 온도 측정하기
표 9. ADC 측정 명령 시퀀스
DEMO1234 Command
Action (Triggered by A/D3210 Bits)
SPI data in
T MB
Measure BAT1/4, BAT2/4, AUX1, AUX2, TEMP1, TEMP2 with 12-bit resolution and 3.5µs conversion rate
0x0040 0x2f01
0x8005 0x0000
0x8006 0x0000
0x8007 0x0000
0x8008 0x0000
0x8009 0x0000
0x800a 0x0000
T W AC 2f01
Trigger ADC scan of BAT1-2, AUX1-2, TEMP1-2;
ADC control word 0x2f01 means:
ADC_control_wr_demand_scan
ADC_control_ AD1011 /* measure AUX1 etc. */
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 0x2f01
T R B1
Read BAT1 result BAT1 _code
0x8005 0x0000
T R B2
Read BAT2 result BAT2_code
0x8006 0x0000
T R A1
Read AUX1 result AUX1 _code
0x8007 0x0000
T R A2
Read AUX2 result AUX2 _code
0x8008 0x0000
T R T1
Read TEMP1 result TEMP1 _code
0x8009 0x0000
T R T2
Read TEMP2 result TEMP2 _code
0x800a 0x0000
3) 터치스크린 예제
다음의 예제는 DEMO1234.EXE 프로그램을 사용하여 터치스크린 데이터를 얻는 방법을 보여준다.
3.1) 저가의 상용 터치스크린 구입하기
"PDA Digitizer/Glasstop"으로 인터넷 검색을 수행하여 적절한 대체 터치스크린을 찾는다. 가격은 투명 터치스크린(clear touch-sensitive glass)의 경우 모델에 따라 또는 글래스가 전체 디스플레이에 부착되어 있는지 여부에 따라 $50 ~ $10 사이이다.
3.2) 터치스크린을 EV 킷에 연결하기
MAX1234 EV 킷은 폭이 10mm 미만인 플렉스 케이블에 연결할 수 있게 해주는 브레이크아웃 헤더 H5/H6을 제공한다. H6 커넥터의 피치는 0.5mm인데, 이는 실제 터치스크린 플렉스 케이블 피치보다 더 작다. 플렉스 케이블을 H6에 꽂고, 래치를 고정시킨 다음, H5에서 4개의 플렉스 케이블 트레이스의 각 중심에 위치한 핀을 선택한다. H5에서 X+, Y+, X-, Y-에 대한 U1 라벨 표시가 있는 테스트 포인트까지 점퍼로 연결한다.
3.3) 터치스크린 연결 확인하기
터치스크린을 맨 처음 연결한 경우에는 다음 절차대로 X 및 Y 연결이 올바른지 확인한다. 터치스크린 연결에서 몇 가지 다른 변환이 가능하지만, 대부분 제대로 작동하지 않는다. 이 예에서는 X- = 왼쪽, X+ = 오른쪽, Y- = 상단, Y+ = 하단으로 가정한다.
표 10. 터치스크린 물리적 연결 확인 명령 시퀀스
DEMO1234 Command
Action
SPI data in
Verification
Connect DVM to X+/GND
T MD
No measurement; drive Y+,Y-
0x0040 0x3701
Touch top left
X+ = approx. Y-
Touch top right
X+ = approx. Y-
Touch bottom left
X+ = approx. Y+
Touch bottom right
X+ = approx. Y+
Connect DVM to Y+/GND
T ME
No measurement; drive X+,X-
0x0040 0x3b01
Touch top left
Y+ = approx. X-
Touch top right
Y+ = approx. X+
Touch bottom left
Y+ = approx. X-
Touch bottom right
Y+ = approx. X+
표 11. 터치스크린 연결 문제 교정하기
Symptom
Correction
Touch coordinates are mirrored top-to-bottom
Swap the Y+ and Y- connections
Touch coordinates are mirrored left-to-right
Swap the X+ and X- connections
Touch coordinates are rotated 180 degrees
Swap the X+ and X- connections, and swap the Y+ and Y- connections
Touch coordinates are mirrored diagonally
Swap the X+ and Y+ connections, and swap the X- and Y- connections
Touch coordinates do not seem to track, and the distortion is not a simple flip/rotate/mirror transformation
Swap the X+ and Y+ connections; if distortion persists, swap the X+ and Y- connections; if distortion still persists, disconnect touch screen and use DVM to verify X+ to X- resistance and Y+ to Y- resistance; verify with no touch X+ and X- are isolated from Y+ and Y-
3.4) 터치 검출하기: 스캔 요구
요구 시 터치를 검출하고 터치 위치를 디지털화 하도록 MAX1234를 구성하려면 레지스터 0x40(ADC 제어)에 PENSTS=0 및 ADSTS=0을 쓴다(MAX1233/MAX1234 데이터 시트의 표 6 참조). 레지스터 0x00(X 좌표)을 읽은 후, 다음 터치가 검출되면 PENIRQ-bar 신호가 로우로 래치되며, X, Y 좌표를 측정하기 위해 ADC 제어가 쓰여질 때까지 로우 상태를 유지한다.
표 12. 터치스크린 측정 명령 시퀀스: 스캔 요구
DEMO1234 Command
Action
SPI data in
Verification
T W AC 0b01
Demand scan
0x0040 0x0b01
T R AX
Read conversion result register X
0x8000 0x0000
P R 6
Read PENIRQ-bar pin status
PENIRQ = 1
Touch the touch screen
P R 6
Read PENIRQ-bar pin status
PENIRQ = 0
T M2
Measure X,Y,Z1,Z2
0x0040 0x0b01
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
P R 6
Read PENIRQ-bar pin status
PENIRQ = 1
Touch and hold the touch screen
P R 6
Read PENIRQ-bar pin status
PENIRQ = 0
T M2
Measure X,Y,Z1,Z2
0x0040 0x0b01
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
P R 6
Read PENIRQ-bar pin status
PENIRQ = 0
T M2
Measure X,Y,Z1,Z2
0x0040 0x0b01
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
P R 6
Read PENIRQ-bar pin status
PENIRQ = 0
Release the touch screen
P R 6
Read PENIRQ-bar pin status
PENIRQ = 0
T M2
Measure X,Y,Z1,Z2
0x0040 0x0b01
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
P R 6
Read PENIRQ-bar pin status
PENIRQ = 1
3.5) 터치 검출하기: 자동 스캔
스크린 터치가 검출될 때 터치 위치를 자동으로 디지털화 하도록 MAX1234를 구성하려면, 레지스터 0x40(ADC 제어)에 PENSTS=1 및 ADSTS=0을 쓴다(MAX1233/MAX1234 데이터 시트의 표 6 참조). 스크린이 처음 터치되면 PENIRQ-bar 신호가 짧게 로우를 펄스하고, X 레지스터가 읽혀질 때까지 다시 펄스하지 않는다.
Read the number of times PENIRQ-bar has pulsed low
count = 0
T W AC 8bff
Wait for touch, then scan X,Y,Z1,Z2
0x0040 0x8bff
Touch the touch screen
PENIRQ pulse
I R 1
Read the number of times PENIRQ-bar has pulsed low
count has increased
T R P
Read X,Y,Z1,Z2 conversion results
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
Touch the touch screen
PENIRQ pulse
I R 1
Read the number of times PENIRQ-bar has pulsed low
count has increased
T R P
Read X,Y,Z1,Z2 conversion results
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
Touch the touch screen
PENIRQ pulse
I R 1
Read the number of times PENIRQ-bar has pulsed low
count has increased
T R P
Read X,Y,Z1,Z2 conversion results
0x8000 0x0000
0x8001 0x0000
0x8002 0x0000
0x8003 0x0000
4) 키패드 및 범용 입/출력 핀
다음의 예제는 DEMO1234.EXE 프로그램을 사용하여 키패드를 스캔하고, GPIO를 위해 키 스캐닝 핀을 사용하는 방법을 보여준다.
4.1) 키패드 및 GPIO 핀 구성하기
GPIO 제어 레지스터는 C1-C4 및 R1-R4 핀을 각각 입력, 출력 또는 키패드의 일부로 구성한다(MAX1233/MAX1234 데이터 시트의 표 26 및 27 참조). 이 밖에도, GPIO 풀 업 디스에이블 레지스터를 쓰면 출력 핀을 오픈 드레인 출력으로 구성할 수 있다.
Read the number of times KEYIRQ-bar has pulsed low
count = 0
T W GC 0000
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wait for keypress; maximum debounce and hold times
0x0041 0xbf00
Press and release R1C1 (key "1")
KEYIRQ pulse
I R 0
Read the number of times KEYIRQ-bar has pulsed low
count has increased
T R KB
Read raw keypad result
0x8004 0x0000
0x0001 = R1C1 key
Press and release R2C2 (key "5")
KEYIRQ pulse
I R 0
Read the number of times KEYIRQ-bar has pulsed low
count has increased
T R KB
Read raw keypad result
0x8004 0x0000
0x0020 = R2C2 key
Press and release R3C2 (key "8")
KEYIRQ pulse
I R 0
Read the number of times KEYIRQ-bar has pulsed low
count has increased
T R KB
Read raw keypad result
0x8004 0x0000
0x0040 = R3C2 key
4.4) 키패드에서 개별 키 마스크 오프하기
개별 키 마스크 오프는 키 마스크 레지스터 및 키패드 2 결과 레지스터를 사용하여 수행한다. 마스크된 키는 KPD 레지스터로 스캔되지만, 키패드 2 결과 레지스터에는 보고되지 않는다.
표 17. 키 누름 명령 시퀀스: 개별 키 마스크 오프
DEMO1234 Command
Action
SPI data in
Verification
T W GC 0000
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wait for keypress; maximum debounce and hold times
0x0041 0xbf00
T W KM 0020
Mask only R2C2 key
0x0050 0x0020
Press and release R1C1 (key "1")
T R KB
Read raw keypad result
0x8004 0x0000
0x0001 = R1C1 key
T R K2
Read masked keypad result
0x8011 0x0000
0x0001 = R1C1 key
Press and release R2C2 (key "5")
T R KB
Read raw keypad result
0x8004 0x0000
0x0020 = R2C2 key
T R K2
Read masked keypad result
0x8011 0x0000
0x0000 = no key
Press and release R3C2 (key "8")
T R KB
Read raw keypad result
0x8004 0x0000
0x0040 = R3C2 key
T R K2
Read masked keypad result
0x8011 0x0000
0x0040 = R3C2 key
4.5) 키패드에서 칼럼 마스크 오프하기
키 칼럼 레지스터를 사용하여 전체 칼럼을 마스크 오프한다. 마스크된 칼럼은 스캔되지 않으므로, KPD 레지스터는 해당 칼럼의 키를 전혀 검출하지 못한다.
표 18. 키 누름 명령 시퀀스: 키의 전체 칼럼 마스크 오프
DEMO1234 Command
Action
SPI data in
Verification
T W GC 0000
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1); GPIO outputs: none; GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wait for keypress; maximum debounce and hold times
0x0041 0xbf00
T W KK 2000
Mask entire C2 column
0x0051 0x2000
Press and release R1C1 (key "1")
T R KB
Read raw keypad result
0x8004 0x0000
0x0001 = R1C1 key
Press and release R2C2 (key "5")
T R KB
Read raw keypad result
0x8004 0x0000
(previous value)
Press and release R3C2 (key "8")
T R KB
Read raw keypad result
0x8004 0x0000
(previous value)
Press and release R2C3 (key "6")
T R KB
Read raw keypad result
0x8004 0x0000
0x0200 = R2C3 key
5) 전력 소비 관리하기
표 19. 파워 오프 명령
DEMO1234 Command
Action
SPI data in
Verification
T W AC C000
Power off ADC
0x0040 0xc000
—
T W AC 0300
Power off internal reference
0x0040 0x0300
REF = not driven
T W DC 8000
Disable DAC
0x0042 0x8000
DACOUT = 0.0V
T W KC C000
Power off keypad
0x0041 0xc000
—
6) 메뉴 시스템
전체 소스 코드는 MINIQUSB+ 모듈에 연결되는 다음의 콘솔 메뉴 시스템을 구현한다.
CmodComm 테스트 프로그램 메인 메뉴 - 연결 전
A) adjust timing parameters
L) CmodLog... functions
C) connect
D) Debug Messages
X) exit
C (연결) 명령에 대한 응답
C
Hardware supports optimized native SMBus commands.
Board connected.
Got board banner: Maxim MINIQUSB V01.05.41 >
Firmware version is OK.
(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...
메인 메뉴 - 연결 후 나타남
T) Test the device
8) CmodP8Bus... functions
A) adjust timing parameters
L) CmodLog... functions
P) CmodPin... functions
S) CmodSpi... functions
M) CmodSMBus... functions
$) CmodCommStringWrite list of hex codes
R) CmodBoardReset
D) Disconnect
테스트 메뉴 명령 - 연결 후 나타남
R) Read register
W) Write register
M0) measure no measurement; configure reference
M1) measure X,Y
M2) measure X,Y,Z1,Z2
M3) measure X
M4) measure Y
M5) measure Z1,Z2
M6) measure BAT1/4
M7) measure BAT2/4
M8) measure AUX1
M9) measure AUX2
MA) measure TEMP1
MB) measure BAT1/4,BAT2/4,AUX1,AUX2,TEMP1,TEMP2
MC) measure TEMP1,TEMP2
MD) no measurement; drive Y+,Y-
ME) no measurement; drive X+,X-
MF) no measurement; drive Y+,X-
.) Exit this menu