ENGLISH 简体中文 日本語 한국어  

    Login | Register 


   
 
请输入关键词或器件型号    




应用笔记4533

An LED Target-Practice Game Uses the MAXQ2000 and MAX7312

Gordon Lee

Abstract: This application note is an LED target-practice game. The game demonstrates the capabilities of the MAXQ2000 microcontroller (MAXQ20 core) and the MAX7312 port expander. All the firmware required to interface the two devices is provided.

Introduction

This application note provides all the firmware required to interface the MAXQ2000 microcontroller (MAXQ20 core) to the MAX7312 16-bit port expander. The application example is an LED target-practice game. The example assembly program was written and assembled specifically for the MAXQ2000 using the free IAR Embedded Workbench® IDE version 2.10A.

Hardware Overview

The MAX7312 is a 2-wire-interfaced 16-bit I/O port expander with interrupt and hot-insertion protection. Using this application note and a MAX7312 EV (evaluation) kit, the user can create an LED target-practice game. The EV kit's red and green LEDs will quickly roll up and down. The game's objective is to press one of the pushbuttons when the red and green LED lights meet at the center.

The MAX7312 EV kit consists of the MAX7312, the MAXQ2000 microcontroller, all required passive components, and a proven PCB layout. The MAX7312 EV kit schematics are shown in Figures 1 and 2.

For more information on the MAXQ2000 microcontroller, please order the MAXQ2000 EV kit. The MAXQ2000 EV kit contains a complete set of software, hardware, sample code, and documentation needed to start designing with MAXQ2000. Schematics for the MAXQ2000 EV kit are available in the data sheet.

Figure 1. The MAX7312EV kit schematic, one of two schematics.
More detailed image
(PDF, 292kB)
Figure 1. The MAX7312EV kit schematic, one of two schematics.

Figure 2. MAX7312EV kit schematic, second of two schematics.
More detailed image
(PDF, 332kB)
Figure 2. MAX7312EV kit schematic, second of two schematics.

Firmware Overview

The example firmware program (see below) communicates to the MAX7312 by bit-banging an I²C interface on the MAXQ2000's general-purpose input/output (GPIO) ports. The MAXQ2000's 20MHz system clock allows the bit-banged I²C interface to run at up to 400kHz. The user modifies the maxqi2c.h header file to select the speed of the I²C interface and which GPIO ports will be used as SDA and SCL. Please refer to application note 3588, "Software I²C Driver for the MAXQ2000 Microcontroller," for more information.

Once the MAX7312 EV kit is powered on, the MAXQ2000 automatically detects the I²C address of the MAX7312. The program then starts to configure the MAX7312's port 1 GPIOs to create the LED lights' rolling effect. The port 2 GPIOs 8 and 9 are configured as input ports, and the firmware reads the states of the pushbuttons through those ports.

The game challenges the player to press a pushbutton when the red and green LED scrolling lights meet at the center. If the button is pressed when the LEDs meet, then MAXQ2000 microcontroller will detect it and all LEDs will flash indicating that the user wins the game.

Table 1 shows all of the I²C operations that are needed for this game application.

Table 1. I²C Operations
I²C/SMBus Protocol Application Purpose Device Slave Address Register Address
Read port 2 input register Read the states of the pushbuttons 0x40 0x01
01000000b 00000001b
Write configuration registers to port 1 Configure the I/O direction for port 1 0x40 0x06
01000000b 00000110b
Write configuration registers to port 2 Configure port 2 GPIOs 8 and 9 as input ports 0x40 0x07
01000000b 00000111b
Write output port register to port 1 Turn LED lights on or off 0x40 0x02
01000000b 00000010b

The source code for this application is available for download.



IAR is a trademark of IAR Systems AB.


相关型号  APP 4533: Sep 28, 2009
MAX7312 2线接口、16位、输入/输出端口扩展器,带有中断和热插入保护 完整的数据资料
(PDF, 308kB)
免费样品

自动更新
需要自动接收最新发布的应用笔记吗?请订阅EE-Mail™ (English only)。




我们期待您的反馈!
喜欢?不喜欢?有待改善?或为我们提供建议?请与我们联系 — 我们将根据您的意见或建议改善我们的工作。 网页评价或提供建议

 

下载,PDF格式下载,PDF格式 (45kB)
 AN4533, AN 4533, APP4533, Appnote4533, Appnote 4533

        •         •         •     隐私权政策     •     法律声明

    © 2009 Maxim Integrated Products版权所有