工业控制 | 能源技术 | 汽车电子 | 通信网络 | 安防监控 | 智能电网 | 移动手持 | 无线技术 | 家用电器 | 数字广播 | 消费电子 | 应用软件 | 其他方案

电路设计->光电电路图->其他光电实用电路图->MAX1233/MAX1234触摸屏控制器入门

MAX1233/MAX1234触摸屏控制器入门

作者:dolphin时间:2016-09-21

MAX1233/MAX1234触摸屏控制器入门

摘要:本应用笔记介绍怎样使用MAX1233/MAX1234触摸屏控制器的功能。所提供的简化控制台菜单系统支持对MAX1233/MAX1234器件寄存器的底层直接访问。每一寄存器在32个SPI时钟周期内完成读写操作。软件对每一寄存器使用简短的助记名。使用MAX1234评估板(EV Kit)和MINIQUSB+命令模块时,软件支持最大底层控制。在随附的zip文件中,提供所有源代码。

MAX1233的工作方式和

  • MAX1234一致,只是MAX1233采用3.3V供电,而不是5.0V。MAX1234评估板上的跳接器JU1使MAX1234工作在3.3V,以仿真MAX1233。

    注意:符号"/" (例如,/CS)表示CS、PENIRQ、KEYIRQ和BUSY引脚为低电平有效。

    内容目录
    MAX1233/MAX1234触摸屏控制器入门
    1.1) 需要的硬件
    1.2) MINIQUSB+固件更新说明
    1.3) 设置
    1.4) 步骤
    1.5) 解释SPI data in实例格式
    2) 模拟I/O实例
    2.1) 控制DAC输出电压
    2.2) 选择ADC基准电源模式
    2.3) 测量外部电压输入AUX1和AUX2
    2.4) 将AUX1和AUX2转换结果译为物理值
    2.5) 测量外部电压输入BAT1和BAT2
    2.6) 将BAT1和BAT2转换结果译为物理值
    2.7) 测量内部温度TEMP1和TEMP2
    2.8) 将TEMP1转换结果译为物理值
    2.9) 将TEMP1和TEMP2转换结果译为物理值
    2.10) 测量外部电压输入AUX1、AUX2、BAT1、BAT2和温度
    3) 触摸屏实例
    3.1) 低成本商用触摸屏
    3.2) 连接触摸屏和评估板
    3.3) 验证触摸屏的连接
    3.4) 检测触摸屏操作:根据需要扫描
    3.5) 检测触摸屏操作:自动扫描
    4) 键盘和通用输入/输出引脚
    4.1) 配置键盘和GPIO引脚
    4.2) 读写GPIO引脚
    4.3) 检测按键:自动扫描
    4.4) 从键盘中屏蔽单个按键
    4.5) 从键盘中屏蔽一列
    5) 管理功耗
    6) 菜单系统
    6.1) 寄存器读/写命令
    6.2) 中断和状态引脚命令
    6.3) 加入到更新后的MINIQUSB+固件中的命令
    7) 结论
    1.1) 需要的硬件
    • Maxim MAX1234评估板 (MAX1234EVKIT)
    • Maxim MINIQUSB+ (包括USB A-B电缆和MINIQUSB-X+扩展板)
    • Windows® 2000/XP PC,支持USB。
    • 四线阻性触摸屏(例如,PDA数字转换器/玻璃屏等)
    • 可选:测量DAC输出电压的DMM
    • 可选:驱动AUX和BAT输入的电压源
    • 可选:示波器,用于观察/PENIRQ和/KEYIRQ引脚上的自动扫描中断脉冲。
    1.2) MINIQUSB+固件更新说明MAX1233/MAX1234要求/CS引脚在第一次转换结束之前,解除高电平置位;否则,ADC将无法存储转换结果。在使用本应用笔记之前,必须更新标准MINIQUSB+模块固件,使SPI接口/CS引脚在第32个SCLK 1.4µs内解除置位。在2MHz时,32位自动/CS受控模式将/CS保持低电平21.70µs。只需要对MAXQ2000微控制器非易失闪存MINIQUSB+固件更新一次。这一新固件和标准01.05.39基本固件后向兼容。

    除了提高SPI接口的/CS时序之外,固件更新还包括中断驱动脉冲累加器,在MAX1233/MAX1234配置为自动扫描模式时,支持验证/PENIRQ和/KEYIRQ是否发送其自清除中断脉冲。/PENIRQ的持续时间取决于所配置的ADC转换率,/KEYIRQ的持续时间取决于所配置的开关反弹时间。

    1.3) 设置下载并解压缩应用笔记文件 (ZIP, 2.4MB)。

    根据图1来组装硬件。
    1. 按照表1连接MAX1234评估板连接器J1和MINIQUSB-X+扩展电路板(包含在MINIQUSB+中)。可以采用3M®内部连接器922576-40来替代连接MAX1234评估板的焊线,将其插入到J1中,以提供方便的连接点。不要连接终端模块TB1。

      表1. MAX1234评估板和MINIQUSB+电路板之间的连接设置 MAX1234 SignalMAX1234 EV KitMINIQUSB-X+MINIQUSB SignalGNDJ1-1H2-8GNDVCCJ1-7H2-13.3V supply from MINIQUSB+BUSY-BarJ1-27H2-7GPIO-K7 (MAXQ2000-INT2)PENIRQ-BarJ1-29H1-3GPIO-K6 (MAXQ2000-INT1)KEYIRQ-BarJ1-31H1-8GPIO-K5 (MAXQ2000-INT0)DOUTJ1-35*H2-2MISO (SPI master in, slave out)DINJ1-36*H2-5MOSI (SPI master out, slave in)SCLKJ1-37*H2-3SCLK (SPI clock)CS-BarJ1-38H2-4CS-bar (SPI chip select)USB+5VJ1-5J4-7USB+5V supply from PC* 注释:必须通过连接器J1来驱动MAX1234评估板数字输入,不能直接将其驱动至U1周围的测试点。必须采用板上MAX1841电平转换器来驱动MAX1234评估板数字信号。

    2. 将MINIQUSB+插入到扩展板的顶部。
    3. 连接MINIQUSB+和PC的USB端口。如果这是MINIQUSB+第一次和PC连接,将出现即插即用向导。指南窗口将提示器件驱动器(它包含在随附zip文件中)的安装位置。
    4. 启动固件更新批处理文件FWUPDATE.BAT来更新MINIQUSB+固件。
    5. 固件更新完成后,从PC的USB端口断开MINIQUSB+。
    图1. 硬件配置(在后面章节中连接触摸屏)。
    图1. 硬件配置(在后面章节中连接触摸屏)。

    图2. 系统图片,使用一个3M内部连接器来连接MINIQUSB+和MAX1234评估板。
    图2. 系统图片,使用一个3M内部连接器来连接MINIQUSB+和MAX1234评估板。

    1.4) 步骤
    1. 将MAX1234评估板跳接器JU1设置到“MAX1234”位置。
    2. 将MINIQUSB+连接至PC的USB端口。确定DACOUT电压 = mid-scale (2.2V)。
    3. 启动DEMO1234.EXE程序。屏幕上将出现控制台。
    4. 在控制台中输入下面的命令序列。
    表2. 连接并验证命令序列

    DEMO1234 Command*Expected Program Output

    SPI data inVerification**

    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=http:///article/88/131/app/2008/0x00ff (no bits defined for this register)) result = 10x000b 0x00ffDACOUT = 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 0x0000Data buffer = 0x00ff

    T W DD 80

    Write_Register(regAddr=0x000b wr_DAC_data , data=http:///article/88/131/app/2008/0x0080 (no bits defined for this register)) result = 10x000b 0x0080DACOUT = 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 0x0000data buffer = 0x0080* DEMO1234 Command命令列出了输入到DEMO1234.exe程序中的命令。
    ** Verification列出了可以进行的物理测试,验证所执行的命令。

    1.5) SPI data in实例格式SPI data in一列列出了驱动至MAX1233/MAX1234 DIN引脚的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。写入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 CommandAction

    SPI data inMAX1233 (3.3V)MAX1234 (5.0V)

    T W DD FFDACOUT = full-scale

    0x000b 0x00ffDACOUT = 2.96VDACOUT = 4.48V

    T W DD 00DACOUT = 0V

    0x000b 0x0000DACOUT = 0.0VDACOUT = 0.0V

    T W DD 80DACOUT = mid-scale

    0x000b 0x0080DACOUT = 1.485VDACOUT = 2.25V

    T W DC 8000Disable DAC

    0x0042 0x8000DACOUT = 0.0VDACOUT = 0.0V

    T W DC 0Enable DAC

    0x0042 0x0000DACOUT = 1.485VDACOUT = 2.25V
    2.2) 选择ADC基准电源模式ADC需要一个基准电压。对于典型的嵌入式系统工作,默认设置是fine。在自动上电模式(ADC3210 = 0000,RES10 = 00)下,MAX1233/MAX1234提供自己的内部基准电压。在每次测量之前,内部基准自动上电,测量完成后关断。

    对于第一次诊断,保持上电模式(ADC3210 = 0000,RES10 = 01)支持使用手持式DVM对基准电压进行外部验证。

    ADC扫描选择位设置为0000,写入ADC控制寄存器(0x40),来设置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 CommandAction

    SPI data inVerification

    T W AC 0100Internal 1V reference always powered; write ADC control word with
    ADC3210 = 0000,
    RES10 = 01,
    RFV = 0

    0x0040 0x0100Voltage at pin 12 REF is between 0.98V and 1.02V

    T W AC 0101Internal 2.5V reference always powered; write ADC control word with
    ADC3210 = 0000,
    RES10 = 01,
    RFV = 1

    0x0040 0x0101Voltage at pin 12 REF is between 2.47V and 2.53V

    T W AC 0001Internal 2.5V reference powered when needed; write ADC control word with
    ADC3210 = 0000,
    RES10 = 00,
    RFV = 1

    0x0040 0x0001Voltage at pin 12 REF will be powered only briefly as necessary
    表5. 外部基准命令

    DEMO1234 CommandAction

    SPI data in

    T W AC 0300External 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 CommandAction (Triggered by A/D3210 Bits)

    SPI data in

    T M8Measure AUX1 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x2301

    0x8007 0x0000

    T W AC 2301Trigger 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 A1Read AUX1 result AUX1_code

    0x8007 0x0000

    T M9Measure AUX2 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x2701

    0x8008 0x0000
    2.4) 将AUX1和AUX2转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释AUX1和AUX2转换结果的。

    /* 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 CommandAction (Triggered by A/D3210 Bits)

    SPI data in

    T M6Measure BAT1 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x1b01

    0x8005 0x0000

    T W AC 1b01Trigger 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 B1Read BAT1 result BAT1_code

    0x8005 0x0000

    T W AC 1b21Trigger 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 B1Read BAT1 result BAT1_code

    0x8005 0x0000

    T M7Measure BAT2 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x1f01

    0x8006 0x0000
    2.6) 将BAT1和BAT2转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释BAT1和BAT2转换结果的。注意:通过一个4:1输入分配器来测量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) 测量内部温度TEMP1和TEMP2表8. ADC测量命令序列

    DEMO1234 CommandAction (Triggered by A/D3210 Bits)

    SPI data in

    T MAMeasure TEMP1 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x2b01

    0x8009 0x0000

    T W AC 2b01Trigger 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 T1Read TEMP1 result TEMP1 _code

    0x8009 0x0000

    T MCMeasure TEMP1, TEMP2 with 12-bit resolution and 3.5µs conversion rate

    0x0040 0x3301

    0x8009 0x0000

    0x800a 0x0000

    T W AC 3301Trigger 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 T1Read TEMP1 result TEMP1 _code

    0x8009 0x0000

    T R T2Read TEMP2 result TEMP2 _code

    0x800a 0x0000
    2.8) 将TEMP1转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释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; /* 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++伪代码片断总结了DEMO1234程序是怎样解释TEMP1和TEMP2转换结果的。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 CommandAction (Triggered by A/D3210 Bits)

    SPI data in

    T MBMeasure 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 2f01Trigger 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 B1Read BAT1 result BAT1 _code

    0x8005 0x0000

    T R B2Read BAT2 result BAT2_code

    0x8006 0x0000

    T R A1Read AUX1 result AUX1 _code

    0x8007 0x0000

    T R A2Read AUX2 result AUX2 _code

    0x8008 0x0000

    T R T1Read TEMP1 result TEMP1 _code

    0x8009 0x0000

    T R T2Read TEMP2 result TEMP2 _code

    0x800a 0x0000
    3) 触摸屏实例下面的例子解释了怎样使用DEMO1234.EXE程序来获得触摸屏数据。

    3.1) 低成本商用触摸屏在互联网上搜索"PDA Digitizer/Glasstop",寻找合适的替代触摸屏。高清触摸屏玻璃的价格范围在50美元至10美元之间,价格取决于型号以及玻璃是否全部贴在显示屏上。

    3.2) 连接触摸屏和评估板MAX1234评估板提供突出插头H5/H6来连接10mm柔性电缆或者长度更短的电缆。H6连接器的间距是0.5mm,比实际触摸屏柔性电缆间距更精细。把柔性电缆插入H6,上锁,选择位于四条柔性电缆中每一电缆中心位置的H5引脚。跳接器连接H5和标有U1的X+、Y+、X-以及Y-测试点。

    3.3) 检验触摸屏的连接第一次连接触摸屏时,通过下面的步骤来验证X和Y连接是否正确。可以有几个触摸屏交叉连接,但大部分不会正常工作。在这些例子中,我们假设X- = left,X+ = right,Y- = top,Y+ = bottom。

    表10. 触摸屏物理连接验证命令序列

    DEMO1234 CommandAction

    SPI data inVerificationConnect DVM to X+/GND

    T MDNo measurement; drive Y+,Y-

    0x0040 0x3701Touch top leftX+ = approx. Y-Touch top rightX+ = approx. Y-Touch bottom leftX+ = approx. Y+Touch bottom rightX+ = approx. Y+Connect DVM to Y+/GND

    T MENo measurement; drive X+,X-

    0x0040 0x3b01Touch top leftY+ = approx. X-Touch top rightY+ = approx. X+Touch bottom leftY+ = approx. X-Touch bottom rightY+ = approx. X+
    表11. 纠正触摸屏连接问题 SymptomCorrectionTouch coordinates are mirrored top-to-bottomSwap the Y+ and Y- connectionsTouch coordinates are mirrored left-to-rightSwap the X+ and X- connectionsTouch coordinates are rotated 180 degreesSwap the X+ and X- connections, and swap the Y+ and Y- connectionsTouch coordinates are mirrored diagonallySwap the X+ and Y+ connections, and swap the X- and Y- connectionsTouch coordinates do not seem to track, and the distortion is not a simple flip/rotate/mirror transformationSwap 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信号锁存至低电平,在写入ADC控制寄存器测量X、Y轴之前,保持低电平。

    表12. 触摸屏检测命令序列:根据需要扫描

    DEMO1234 CommandAction

    SPI data inVerification

    T W AC 0b01Demand scan

    0x0040 0x0b01

    T R AXRead conversion result register X

    0x8000 0x0000

    P R 6Read PENIRQ-bar pin statusPENIRQ = 1Touch the touch screen

    P R 6Read PENIRQ-bar pin statusPENIRQ = 0

    T M2Measure X,Y,Z1,Z2

    0x0040 0x0b01

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000

    P R 6Read PENIRQ-bar pin statusPENIRQ = 1Touch and hold the touch screen

    P R 6Read PENIRQ-bar pin statusPENIRQ = 0

    T M2Measure X,Y,Z1,Z2

    0x0040 0x0b01

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000

    P R 6Read PENIRQ-bar pin statusPENIRQ = 0

    T M2Measure X,Y,Z1,Z2

    0x0040 0x0b01

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000

    P R 6Read PENIRQ-bar pin statusPENIRQ = 0Release the touch screen

    P R 6Read PENIRQ-bar pin statusPENIRQ = 0

    T M2Measure X,Y,Z1,Z2

    0x0040 0x0b01

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000

    P R 6Read PENIRQ-bar pin statusPENIRQ = 1
    3.5) 检测触摸屏操作:自动扫描在检测触摸屏操作,配置MAX1234,自动数字化触摸屏的接触位置时,写入寄存器0x40 (ADC控制),其PENSTS=1,ADSTS=0 (请参考MAX1233/MAX1234数据资料的表6)。第一次接触屏幕时,/PENIRQ信号暂时变为低电平,并在读取X寄存器之前不会变化。

    表13. 触摸屏检测命令序列:自动扫描

    DEMO1234 CommandAction

    SPI data inVerificationOptional: connect oscilloscope to PENIRQ-bar

    I C 1 3Configure PENIRQ-bar pulse accumulator: falling-edge trigger

    I 0 1Reset the pulse accumulator

    I R 1Read the number of times PENIRQ-bar has pulsed lowcount = 0

    T W AC 8bffWait for touch, then scan X,Y,Z1,Z2

    0x0040 0x8bffTouch the touch screenPENIRQ pulse

    I R 1Read the number of times PENIRQ-bar has pulsed lowcount has increased

    T R PRead X,Y,Z1,Z2 conversion results

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000Touch the touch screenPENIRQ pulse

    I R 1Read the number of times PENIRQ-bar has pulsed lowcount has increased

    T R PRead X,Y,Z1,Z2 conversion results

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000Touch the touch screenPENIRQ pulse

    I R 1Read the number of times PENIRQ-bar has pulsed lowcount has increased

    T R PRead 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数据资料的表2**表27)。此外,写入GPIO上拉禁止寄存器,将输出引脚配置为开漏输出。

    表14. 键盘和GPIO配置实例

    DEMO1234 CommandAction

    SPI data in

    T W GC FFFFKeypad: none;
    GPIO outputs: C4,C3,C2,C1,R4,R3,R2,R1;
    GPIO inputs: none

    0x004f 0xffff

    T W GC FF00Keypad: none;
    GPIO outputs: none;
    GPIO inputs: C4,C3,C2,C1,R4,R3,R2,R1

    0x004f 0xff00

    T W GC 0000Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1);
    GPIO outputs: none;
    GPIO inputs: none

    0x004f 0x0000

    T W GC C8C0Keypad: (C2,C1) x (R3,R2,R1);
    GPIO outputs: C4,C3;
    GPIO input: R4

    0x004f 0xc8c0

    T W GP 4000GPIO pullup disable: C3

    0x004e 0x4000
    4.2) 读写GPIO引脚GPIO数据寄存器读取GPIO输入引脚,写入GPIO输出引脚。注意:在这些例子中,C3、C4和R4是引脚名称,而不是元件名称。

    表15. GPIO实例

    DEMO1234 CommandAction

    SPI data inVerification

    T W GC C8C0Keypad:
    (C2,C1) x (R3,R2,R1);
    GPIO outputs: C4,C3;
    GPIO input: R4

    0x004f 0xc8c0

    T W GP 4000GPIO pullup disable: C3

    0x004e 0x4000Connect external resistor between C3 pin and DVDDConnect DVM to C4 pin

    T W GD 8000GPIO write C4 = 1

    0x000f 0x8000C4 pin = high

    T W GD 0000GPIO write C4 = 0

    0x000f 0x0000C4 pin = low

    T W GD 8000GPIO write C4 = 1

    0x000f 0x8000C4 pin = high

    T W GD 0000GPIO write C4 = 0

    0x000f 0x0000C4 pin = lowConnect DVM to C3 pin

    T W GD 4000GPIO write C3 = 1

    0x000f 0x4000C3 pin = high

    T W GD 0000GPIO write C3 = 0

    0x000f 0x0000C3 pin = low

    T W GD 4000GPIO write C3 = 1

    0x000f 0x4000C3 pin = high

    T W GD 0000GPIO write C3 = 0

    0x000f 0x0000C3 pin = lowConnect R4 pin to DVDD

    T R GDGPIO read

    0x800f 0x0000Buffer = 0x0800Connect R4 pin to GND

    T R GDGPIO read

    0x800f 0x0000Buffer = 0x0000
    4.3) 检测按键:自动扫描可以配置键盘控制寄存器在探测到有按键按下时,自动扫描键盘。

    表16. 按键命令序列:自动扫描

    DEMO1234 CommandAction

    SPI data inVerificationOptional: connect oscilloscope to KEYIRQ-bar

    I C 0 3Configure KEYIRQ-bar pulse accumulator: falling-edge trigger

    I 0 0Reset the pulse accumulator

    I R 0Read the number of times KEYIRQ-bar has pulsed lowcount = 0

    T W GC 0000Keypad:
    (C4,C3,C2,C1) x (R4,R3,R2,R1);
    GPIO outputs: none;
    GPIO inputs: none

    0x004f 0x0000

    T W KC bf00Wait for keypress;
    maximum debounce and hold times

    0x0041 0xbf00Press and release R1C1 (key "1")KEYIRQ pulse

    I R 0Read the number of times KEYIRQ-bar has pulsed lowcount has increased

    T R KBRead raw keypad result

    0x8004 0x00000x0001 = R1C1 keyPress and release R2C2 (key "5")KEYIRQ pulse

    I R 0Read the number of times KEYIRQ-bar has pulsed lowcount has increased

    T R KBRead raw keypad result

    0x8004 0x00000x0020 = R2C2 keyPress and release R3C2 (key "8")KEYIRQ pulse

    I R 0Read the number of times KEYIRQ-bar has pulsed lowcount has increased

    T R KBRead raw keypad result

    0x8004 0x00000x0040 = R3C2 key
    4.4) 从键盘中屏蔽单个按键使用键盘屏蔽寄存器和键盘2结果寄存器来屏蔽每个按键。屏蔽掉的按键被扫描至KPD寄存器,但是不在键盘2结果寄存器中报告。

    表17. 按键命令序列:屏蔽单个按键

    DEMO1234 CommandAction

    SPI data inVerification

    T W GC 0000Keypad:
    (C4,C3,C2,C1) x (R4,R3,R2,R1);
    GPIO outputs: none;
    GPIO inputs: none

    0x004f 0x0000

    T W KC bf00Wait for keypress;
    maximum debounce and hold times

    0x0041 0xbf00

    T W KM 0020Mask only R2C2 key

    0x0050 0x0020Press and release R1C1 (key "1")

    T R KBRead raw keypad result

    0x8004 0x00000x0001 = R1C1 key

    T R K2Read masked keypad result

    0x8011 0x00000x0001 = R1C1 keyPress and release R2C2 (key "5")

    T R KBRead raw keypad result

    0x8004 0x00000x0020 = R2C2 key

    T R K2Read masked keypad result

    0x8011 0x00000x0000 = no keyPress and release R3C2 (key "8")

    T R KBRead raw keypad result

    0x8004 0x00000x0040 = R3C2 key

    T R K2Read masked keypad result

    0x8011 0x00000x0040 = R3C2 key
    4.5) 从键盘中屏蔽一列使用键盘列寄存器来屏蔽所有列。不扫描屏蔽列,因此,KPD寄存器不会探测这些列中的按键。

    表18. 按键命令序列:屏蔽键盘的一列

    DEMO1234 CommandAction

    SPI data inVerification

    T W GC 0000Keypad:
    (C4,C3,C2,C1) x (R4,R3,R2,R1);
    GPIO outputs: none;
    GPIO inputs: none

    0x004f 0x0000

    T W KC bf00Wait for keypress;
    maximum debounce and hold times

    0x0041 0xbf00

    T W KK 2000Mask entire C2 column

    0x0051 0x2000Press and release R1C1 (key "1")

    T R KBRead raw keypad result

    0x8004 0x00000x0001 = R1C1 keyPress and release R2C2 (key "5")

    T R KBRead raw keypad result

    0x8004 0x0000(previous value)Press and release R3C2 (key "8")

    T R KBRead raw keypad result

    0x8004 0x0000(previous value)Press and release R2C3 (key "6")

    T R KBRead raw keypad result

    0x8004 0x00000x0200 = R2C3 key
    5) 电源管理表19. 关断命令

    DEMO1234 CommandAction

    SPI data inVerification

    T W AC C000Power off ADC

    0x0040 0xc000—

    T W AC 0300Power off internal reference

    0x0040 0x0300REF = not driven

    T W DC 8000Disable DAC

    0x0042 0x8000DACOUT = 0.0V

    T W KC C000Power 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

    6.1) 寄存器读/写命令表20. 读取寄存器助记符

    DEMO1234 CommandMnemonic

    SPI data in

    T R A1Test Read AUX1 register

    0x8007 0x0000

    T R A2Test Read AUX2 register

    0x8008 0x0000

    T R ACTest Read ADC_control register

    0x8040 0x0000

    T R AXTest Read X register

    0x8000 0x0000

    T R AYTest Read Y register

    0x8001 0x0000

    T R AZ1Test Read Z1 register

    0x8002 0x0000

    T R AZ2Test Read Z2 register

    0x8003 0x0000

    T R B1Test Read BAT1 register

    0x8005 0x0000

    T R B2Test Read BAT2 register

    0x8006 0x0000

    T R DCTest Read DAC_control register

    0x8042 0x0000

    T R DDTest Read DAC_data register

    0x800b 0x0000

    T R GCTest Read GPIO_control register

    0x804f 0x0000

    T R GDTest Read GPIO_data register

    0x800f 0x0000

    T R GPTest Read GPIO_pullup register

    0x804e 0x0000

    T R K1Test Read KPDATA1 register

    0x8010 0x0000

    T R K2Test Read KPDATA2 register

    0x8011 0x0000

    T R KBTest Read KPD register

    0x8004 0x0000

    T R KCTest Read KEY_control register

    0x8041 0x0000

    T R KKTest Read KPCOLMASK register

    0x8051 0x0000

    T R KMTest Read KPKEYMASK register

    0x8050 0x0000

    T R T1Test Read TEMP1 register

    0x8009 0x0000

    T R T2Test Read TEMP2 register

    0x800a 0x0000
    表21. 写入寄存器助记符

    DEMO1234 CommandMnemonic

    SPI data in

    T W AC hexValueTest Write ADC_control register

    0x0040 hexValue

    T W DC hexValueTest Write DAC_control register

    0x0042 hexValue

    T W DD hexValueTest Write DAC_data register

    0x000b hexValue

    T W GC hexValueTest Write GPIO_control register

    0x004f hexValue

    T W GD hexValueTest Write GPIO_data register

    0x000f hexValue

    T W GP hexValueTest Write GPIO_pullup register

    0x004e hexValue

    T W KC hexValueTest Write KEY_control register

    0x0041 hexValue

    T W KK hexValueTest Write KPCOLMASK register

    0x0051 hexValue

    T W KM hexValueTest Write KPKEYMASK register

    0x0050 hexValue
    表22. 触摸屏测量命令序列

    DEMO1234 CommandAction (Triggered by A/D3210 Bits)

    SPI data in Sequence

    T M1Measure X,Y

    0x0040 0x0701

    0x8000 0x0000

    0x8001 0x0000

    T M2Measure X,Y,Z1,Z2

    0x0040 0x0b01

    0x8000 0x0000

    0x8001 0x0000

    0x8002 0x0000

    0x8003 0x0000

    T M3Measure X

    0x0040 0x0f01

    0x8000 0x0000

    T M4Measure Y

    0x0040 0x1301

    0x8001 0x0000

    T M5Measure Z1,Z2

    0x0040 0x1701

    0x8002 0x0000

    0x8003 0x0000

    T MDNo measurement; drive Y+,Y-

    0x0040 0x3701

    T MENo measurement; drive X+,X-

    0x0040 0x3b01

    T MFNo measurement; drive Y+,X-

    0x0040 0x3f01
    6.2) 中断和状态引脚命令表23. 引脚状态读取命令

    DEMO1234 CommandAction

    SPI data in

    P R 5Read KEYIRQ-bar pin statusN/A

    I C 0 3Enable KEYIRQ-bar falling-edge trigger pulse accumulatorN/A

    I C 0 1Enable KEYIRQ-bar rising-edge trigger pulse accumulatorN/A

    I C 0 0Disable KEYIRQ-bar pulse accumulatorN/A

    I R 0Read the number of times KEYIRQ-bar has pulsed lowN/A

    I 0 0Clear the KEYIRQ-bar pulse accumulatorN/A

    P R 6Read PENIRQ-bar pin statusN/A

    I C 1 3Enable PENIRQ-bar falling-edge trigger pulse accumulatorN/A

    I C 1 1Enable PENIRQ-bar rising-edge trigger pulse accumulatorN/A

    I C 1 0Disable PENIRQ-bar pulse accumulatorN/A

    I R 1Read the number of times PENIRQ-bar has pulsed lowN/A

    I 0 1Clear the PENIRQ-bar pulse accumulatorN/A

    P R 7Read BUSY-bar pin statusN/A
    6.3) 加入到更新后的MINIQUSB+固件中的命令表24. 更新后MINIQUSB+固件01.05.40支持的SPI命令

    DEMO1234 CommandActionCPOLCPHACS-Bar ControlAF Length

    S C L0Configure SPI for CPOL=00—GPIO-K91 byte

    S C L1Configure SPI for CPOL=11—GPIO-K91 byte

    S C A0Configure SPI for CPHA=0—0GPIO-K91 byte

    S C A1Configure SPI for CPHA=1—1GPIO-K91 byte

    S C C0Configure SPI for 8-bit——GPIO-K91 byte

    S C C1Configure SPI for 8-bit auto-CS-bar——Automatic1 byte

    S C C2Configure SPI for 16-bit auto-CS-bar——Automatic2 bytes

    S C C3Configure SPI for 24-bit auto-CS-bar——Automatic3 bytes

    S C C4Configure SPI for 32-bit auto-CS-bar——Automatic4 bytes

    2 AE 00Configure SPI for 8-bit00GPIO-K91 byte

    2 AE 01Configure SPI for 8-bit01GPIO-K91 byte

    2 AE 02Configure SPI for 8-bit10GPIO-K91 byte

    2 AE 03Configure SPI for 8-bit11GPIO-K91 byte

    2 AE 08Configure SPI for 8-bit auto-CS-bar00Automatic1 byte

    2 AE 09Configure SPI for 8-bit auto-CS-bar01Automatic1 byte

    2 AE 0AConfigure SPI for 8-bit auto-CS-bar10Automatic1 byte

    2 AE 0BConfigure SPI for 8-bit auto-CS-bar11Automatic1 byte

    2 AE 18Configure SPI for 16-bit auto-CS-bar00Automatic2 bytes

    2 AE 19Configure SPI for 16-bit auto-CS-bar01Automatic2 bytes

    2 AE 1AConfigure SPI for 16-bit auto-CS-bar10Automatic2 bytes

    2 AE 1BConfigure SPI for 16-bit auto-CS-bar11Automatic2 bytes

    2 AE 28Configure SPI for 24-bit auto-CS-bar00Automatic3 bytes

    2 AE 29Configure SPI for 24-bit auto-CS-bar01Automatic3 bytes

    2 AE 2AConfigure SPI for 24-bit auto-CS-bar10Automatic3 bytes

    2 AE 2BConfigure SPI for 24-bit auto-CS-bar11Automatic3 bytes

    2 AE 38Configure SPI for 32-bit auto-CS-bar00Automatic4 bytes

    2 AE 39Configure SPI for 32-bit auto-CS-bar01Automatic4 bytes

    2 AE 3AConfigure SPI for 32-bit auto-CS-bar10Automatic4 bytes

    2 AE 3BConfigure SPI for 32-bit auto-CS-bar11Automatic4 bytes

    2 AF xxPerform an 8-bit SPI transfer (CS-bar = GPIO or auto-CS-bar = 1-byte)———1 byte

    3 AF xx xxPerform a 16-bit SPI transfer (requires auto-CS-bar = 2-byte mode)———2 bytes

    4 AF xx xx xxPerform a 24-bit SPI transfer (requires auto-CS-bar = 3-byte mode)———3 bytes

    5 AF xx xx xx xxPerform a 32-bit SPI transfer (requires auto-CS-bar = 4-byte mode)———4 bytes

    2 F9 0Drive CS-bar pin low——GPIO-K9—

    2 F9 1Drive CS-bar pin high——GPIO-K9—
    表25. 更新后MINIQUSB+固件01.05.41中的中断脉冲累加器命令

    DEMO1234 CommandActionIntGPIO Input

    Firmware Command

    2 C3 00Query which of the C3 commands are supported; the return value is a 2-byte bitmap of commands C300 to C30F, msb first——

    C3 00

    I Q 0Query configuration of pulse accumulatorINT0GPIO-K5

    C3 01 00

    I Q 1Query configuration of pulse accumulatorINT1GPIO-K6

    C3 01 01

    I Q 2Query configuration of pulse accumulatorINT2GPIO-K7

    C3 01 02

    I Q 3Query configuration of pulse accumulatorINT3GPIO-K8

    C3 01 03

    I C 0 0Configure pulse accumulator: disable interruptINT0GPIO-K5

    C3 02 00 00

    I C 1 0Configure pulse accumulator: disable interruptINT1GPIO-K6

    C3 02 01 00

    I C 2 0Configure pulse accumulator: disable interruptINT2GPIO-K7

    C3 02 02 00

    I C 3 0Configure pulse accumulator: disable interruptINT3GPIO-K8

    C3 02 03 00

    I C 0 1Configure pulse accumulator: rising-edge triggerINT0GPIO-K5

    C3 02 00 01

    I C 1 1Configure pulse accumulator: rising-edge triggerINT1GPIO-K6

    C3 02 01 01

    I C 2 1Configure pulse accumulator: rising-edge triggerINT2GPIO-K7

    C3 02 02 01

    I C 3 1Configure pulse accumulator: rising-edge triggerINT3GPIO-K8

    C3 02 03 01

    I C 0 3Configure pulse accumulator: falling-edge triggerINT0GPIO-K5

    C3 02 00 03

    I C 1 3Configure pulse accumulator: falling-edge triggerINT1GPIO-K6

    C3 02 01 03

    I C 2 3Configure pulse accumulator: falling-edge triggerINT2GPIO-K7

    C3 02 02 03

    I C 3 3Configure pulse accumulator: falling-edge triggerINT3GPIO-K8

    C3 02 03 03

    I R 0Read pulse accumulatorINT0GPIO-K5

    C3 03 00

    I R 1Read pulse accumulatorINT1GPIO-K6

    C3 03 01

    I R 2Read pulse accumulatorINT2GPIO-K7

    C3 03 02

    I R 3Read pulse accumulatorINT3GPIO-K8

    C3 03 03

    I 0 0Clear pulse accumulatorINT0GPIO-K5

    C3 04 00

    I 0 1Clear pulse accumulatorINT1GPIO-K6

    C3 04 01

    I 0 2Clear pulse accumulatorINT2GPIO-K7

    C3 04 02

    I 0 3Clear pulse accumulatorINT3GPIO-K8

    C3 04 03

    I S 0 xxSet pulse accumulator count xx = 0 to 255INT0GPIO-K5

    C3 05 00 xx

    I S 1 xxSet pulse accumulator count xx = 0 to 255INT1GPIO-K6

    C3 05 01 xx

    I S 2 xxSet pulse accumulator count xx = 0 to 255INT2GPIO-K7

    C3 05 02 xx

    I S 3 xxSet pulse accumulator count xx = 0 to 255INT3GPIO-K8

    C3 05 03 xx
    7) 结论这些实例简要介绍了怎样使用MAX1233/MAX1234的主要功能模块,利用简化的控制台C++程序来测量并控制硬件。如果需要深入了解详细信息,请参考MAX1233/MAX1234数据资料。



  • 评论

    技术专区