ST72T251G2B6 [STMICROELECTRONICS]

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI, I2C AND 2 TIMERS; 8位MCU 4〜 8K ROM / OTP / EPROM , 256字节RAM , ADC , WDG , SPI , I2C和2定时器
ST72T251G2B6
型号: ST72T251G2B6
厂家: ST    ST
描述:

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI, I2C AND 2 TIMERS
8位MCU 4〜 8K ROM / OTP / EPROM , 256字节RAM , ADC , WDG , SPI , I2C和2定时器

微控制器和处理器 外围集成电路 光电二极管 可编程只读存储器 电动程控只读存储器 时钟
文件: 总11页 (文件大小:70K)
中文:  中文翻译
下载:  下载PDF数据表文档文件
APPLICATION NOTE  
ST7 KEYPAD DECODING TECHNIQUES, IMPLEMENTING  
WAKE-UP ON KEYSTROKE  
by Microcontroller Division Application Team  
INTRODUCTION  
The goal of this application note is to present an example of the use of the HALT mode.  
In this application, the MCU (here a ST72251) is waked up by an external interrupt caused by  
someone pressed a key on the 4x4 matrixed keypad.  
1 ST7 / KEYBOARD INTERFACE  
Rows are connected to inputs with pull-up and interrupts (Port C). Columns are connected to  
Port A configured as output. The result of the interrupt (the value of the pressed key) is sent on  
LEDS (Port B) and stored into the X register. In our configuration, we have to add 4 pull-up re-  
sistors on Port A (from PA0 to PA3) to be able to apply a high level on the corresponding pads.  
Figure 1. ST7 / keypad interface set-up  
4x100k  
8x560  
V
PC0  
PC1  
PC2  
PC3  
DD  
ST7  
PA0  
PA1  
PA2  
PA3  
GND  
AN980/1098  
1/10  
1
ST72251 CONFIGURATION  
2 ST72251 CONFIGURATION  
The application has been validated with a ST72251. Its configuration is described in this part.  
Refer to your datasheet for more details.  
2.1 I/O CONTROL  
Rows are connected to pins configured as inputs (Port C as input with pull up and interrupts).  
Columns are connected to pins configured as outputs (Port A).  
External interrupts are caused by a low level applied to a pin of Port C (caused by a key  
pressed), they wake up the MCU which was in HALT mode.  
Port B is configured as outputs to send the value of the pressed key on LEDS.  
Please, refer to the Data Book to configure pins properly.  
2.2 MISCELLANEOUS REGISTER  
Bits 7 and 6 have to be set to configure events correctly: the external interrupt (EI1) has here  
to be caused by a falling edge only.  
Please, refer to the datasheet for more details.  
2.3 HALT MODE  
The HALT instruction places the ST72251 in its lowest power consumption mode. The core  
and all peripherals are frozen. In this mode, the internal oscillator is turned off, causing all in-  
ternal processing to be halted. The data remain unchanged. During the HALT mode, external  
interrupts are still enabled. The MCU stays in this state until an external interrupt or a reset oc-  
curs. Then the internal oscillator is restarted and the core waits for 4096 CPU clock cycles  
(512 µs for a f  
= 8MHz) before running the external interrupt subroutine. Then the MCU  
CPU  
comes back to the main program (in our application to the HALT state).  
Please, refer to the datasheet for more details.  
3 EXTERNAL INTERRUPTS  
The MCU is in HALT mode. When a key is pressed, a low level is applied to the pin corre-  
sponding to the row the key belongs (pins configured as inputs with pull-up). It’s a falling edge  
applied to a pin of Port C which creates an external interrupt (EI1) and wakes up the MCU. The  
MCU executes then the external interrupt subroutine (decoding the pressed key) and comes  
back to its previous state (HALT state in the main program).  
2/10  
KEYPAD  
4 KEYPAD  
The keypad used is a 4x4 matrixed keypad. Rows are connected to pins configured as inputs  
with pull-up. So the initial state of these pins are a high level (1). When a key is pressed, a low  
level is applied to the corresponding pin. For this reason, the keypad is coded as follows:  
Table 1. Key values  
row  
column  
value  
row  
column  
value  
KEY  
KEY  
value  
value  
1
2
3
F
4
5
6
E
0x0E  
0x0E  
0x0E  
0x0E  
0x0D  
0x0D  
0x0D  
0x0D  
0x0E  
0x0D  
0x0B  
0x07  
0x0E  
0x0D  
0x0B  
0x07  
7
8
0x0B  
0x0B  
0x0B  
0x0B  
0x07  
0x07  
0x07  
0x07  
0x0E  
0x0D  
0x0B  
0x07  
0x0E  
0x0D  
0x0B  
0x07  
9
D
A
0
B
C
1
2
3
6
F
E
PC0  
PC1  
PC2  
PC3  
4
5
7
8
D
C
9
B
0
A
PA1  
PA0  
PA2  
PA3  
You have to press the chosen key at least 0.5 to 1 second depending on which key you  
choose (table read from keypad_top to keypad). The faster the key is read into the table, the  
faster it will be decoded and the faster the result will be sent on LEDS.  
3/10  
KEYPAD  
The keypad code is in the file constant.asm as follows:  
.keypad  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
DC.B  
$0E,$0E,$1  
$0E,$0D,$2  
$0E,$0B,$3  
$0E,$07,$F  
$0D,$0E,$4  
$0D,$0D,$5  
$0D,$0B,$6  
$0D,$07,$E  
$0B,$0E,$7  
$0B,$0D,$8  
$0B,$0B,$9  
$0B,$07,$D  
$07,$0E,$A  
$07,$0D,$0  
$07,$0B,$B  
$07,$07,$C  
;PC0PA0  
;PC0PA1  
;PC0PA2  
;PC0PA3  
;PC1PA0  
;PC1PA1  
;PC1PA2  
;PC1PA3  
;PC2PA0  
;PC2PA1  
;PC2PA2  
;PC2PA3  
;PC3PA0  
;PC3PA1  
;PC3PA2  
;PC3PA3  
keypad_top  
4/10  
FLOWCHARTS  
5 FLOWCHARTS  
Figure 2. Flowchart: Main program  
Initializations  
infinite  
loop  
HALT  
Figure 3. Flowchart: external interrupt (EI1)  
X = 48 (3x16 coded values)  
one column activated  
(PA0...PA3)  
no  
Is there a low level on the  
intersection of the stored  
row and column?  
store into X  
next column  
value  
yes  
corresponding value of the pressed key  
stored into A, X and sent on LEDS  
EXIT  
5/10  
SOFTWARE  
6 SOFTWARE  
The assembly code given below is guidance only. The complete software with all the files can  
be found in the software library.  
st7/  
;thefirstlineisreserved  
;forspecifyingtheinstructionset  
;ofthetargetprocessor  
;************************************************************************  
;TITLE:  
WAKE.ASM  
;AUTHOR:  
PPGMicrocontrollerApplicationsTeam  
Mainprogram(useoftheHaltmodefordecoding  
akeypad).  
;DESCRIPTION:  
;
;
;************************************************************************  
TITLE "WAKE.ASM"  
;thistitlewillappearoneach  
;pageofthelistingfile  
MOTOROLA  
;thisdirectiveforcestheMotorola  
;formatfortheassembly(default)  
#INCLUDEst72251.inc”;includest72251registersandmemorymappingfile  
#INCLUDEconstant.inc;includegeneralconstantsfile  
;***********************************************************************  
;
;
Variables,constantsdefinedandreferencedlocally  
Youcandefineyourownvaluesforalocalreferencehere  
;***********************************************************************  
;************************************************************************  
;
Publicroutines(definedhere)  
;************************************************************************  
WORDS  
segment'rom'  
.Init  
LD A,#$80  
LD MISCR,A  
;interruptsarecausedbyfallingedge(onPortC).  
LD A,#$0F  
LD PBDDR,A  
LD PBOR,A  
;PB0toPB3configuresasoutputs(LEDS).  
;PA0toPA3configuredasoutputs.  
LD PADDR,A  
CLR PAOR  
CLR PADR  
LD A,#$0F  
6/10  
SOFTWARE  
LD PCOR,A  
CLR PCDDR  
CLR PCDR  
;PCOtoPC3configuredasinputwithpull-upandinterrupt.  
RET  
.delay_45  
LD A,#200  
loop2 LD X,#$FF  
loop1 DEC X  
JRNE loop1  
DEC A  
JRNE loop2  
RET  
;**********************************************************  
Programcode  
;
;**********************************************************  
.main  
CALL Init  
loop  
HALT  
;MCUputinlowestpowermode.  
JRA loop  
;Infiniteloop,waitaninterruptoccurs.  
;*****************************************************************  
;Thissetofinstructionsusessimpleassemblymnemoniques.  
;Wecannoticethatthelooplabelisdefinedonlylocally(nodot  
;infrontofit)soitcannotbeseenbyothersmoduleslinked  
;withthisfile.  
;*****************************************************************  
;
;
;
;
;
********************************************  
*
*
* INTERRUPTSUB-ROUTINESLIBRARYSECTION *  
*
*
********************************************  
.dummy iret  
.sw_rt iret ;Emptysubroutine.Gobacktomain(iretinstruction)  
.ext0_rtiret  
.ext1_rt  
LD X,#48  
;SizeofthetablestoredinX.  
;3x16codedvalues.  
begin  
7/10  
SOFTWARE  
LD A,PADR  
OR A,#$0F  
;Outputsforcedto1(initialvalue).  
AND A,({keypad+1},X)  
LD PADR,A  
;onecolumnofthetestedrowisactivated.  
PUSH X  
CALL delay_45  
POP X  
;wait45ms(debouncingprocedure).  
LD A,PCDR  
AND A,#$0F  
CP A,(keypad,X)  
JREQ OK  
;valueofPortCstoredintoA.  
;searchofthelowlevelcolumnaftercolumn.  
;ifkeyfound->OK.  
DEC X  
DEC X  
DEC X  
;3timestohavenextvalueofthecolumn.  
;doitagaintoreadthewholetable(matrix).  
JRPL begin  
JRA exit  
OK  
LD A,({keypad+2},X)  
LD X,A  
;StorethekeyvalueinA.  
;CopyitintoX.  
LD PBDR,X  
;OutputtheresultonLEDS.  
exit  
CLR PADR  
CLR PCDR  
iret  
.spi_rt iret  
.tima_rtiret  
.timb_rtiret  
.i2c_rt iret  
segment'vectit'  
;*******************************************************************  
;Thislastsegmentshouldalwaysbethereinyourownprograms.  
;Itdefinestheinterruptvectoradressesandtheinterruptroutines'labels  
;consideringthemicrocontrolleryouareusing.  
;RefertotheMCU'sdatasheettoseethenumberofinterruptvector  
;usedandtheiraddresses.  
;RemindthatthisexampleismadeforaST72251basedapplication.  
;*******************************************************************  
8/10  
SOFTWARE  
;*******************************************************************  
;Eachinterruptvectorusestwoaddressesinrom,that'swhatthedirective  
;DC.Wmeans.Itsays"reserveawordlocation(.W)inrom(DC)andcode  
;theroutine'slabelinthosetwoaddresses.  
;Yet,whenaninterruptoccurs,forexamplefromthetimerB,timerb'sroutine  
;address(timb_rt)willbeloadedinthePCandtheprogramwilljumptothis  
;labelifallowed.Itwillexecutethisroutineandthenwillgobacktothemain  
;program(seeinterruptchapterinthedatasheetforamoreprecisedescription  
;ofhowtohandleinterruptsinST72micros).  
;*******************************************************************  
DC.W dummy  
DC.W dummy  
;FFE0-FFE1hlocation  
;FFE2-FFE3hlocation  
.i2c_it  
DC.W i2c_rt ;FFE4-FFE5hlocation  
DC.W dummy  
DC.W dummy  
DC.W dummy  
DC.W dummy  
;FFE6-FFE7hlocation  
;FFE8-FFE9hlocation  
;FFEA-FFEBhlocation  
;FFEC-FFEDhlocation  
.timb_it  
DC.W timb_rt;FFEE-FFEFhlocation  
DC.W dummy ;FFF0-FFF1hlocation  
.tima_it  
.spi_it  
DC.W tima_rt;FFF2-FFF3hlocation  
DC.W spi_rt ;FFF4-FFF5hlocation  
DC.W dummy  
;FFF6-FFF7hlocation  
.ext1_it  
.ext0_it  
.softit  
.reset  
DC.W ext1_rt;FFF8-FFF9hlocation  
DC.W ext0_rt;FFFA-FFFBhlocation  
DC.W sw_rt  
DC.W main  
;FFFC-FFFDhlocation  
;FFFE-FFFFhlocation  
;Thislastlinereferstothefirstline.  
;Itusedbythecompiler/linkertodeterminecodezone  
END;BeawareofthefactthattheENDdirectiveshouldnot  
;standontheleftofthepagelikethelabels'snames.  
9/10  
SOFTWARE  
THE PRESENT NOTE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH INFORMATION  
REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS  
SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO  
ANY CLAIMS ARISING FROM THE CONTENT OF SUCH A NOTE AND/OR THE USE MADE BY CUSTOMERS OF  
THE INFORMATION CONTAINED HEREIN IN CONNEXION WITH THEIR PRODUCTS.  
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences  
of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted  
by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject  
to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not  
authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics.  
The ST logo is a registered trademark of STMicroelectronics  
1998 STMicroelectronics - All Rights Reserved.  
Purchase of I2C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an  
I2C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips.  
STMicroelectronics Group of Companies  
Australia - Brazil - Canada - China - France - Germany - Italy - Japan - Korea - Malaysia - Malta - Mexico - Morocco - The Netherlands -  
Singapore - Spain - Sweden - Switzerland - Taiwan - Thailand - United Kingdom - U.S.A.  
http://www.st.com  
10/10  
This datasheet has been download from:  
www.datasheetcatalog.com  
Datasheets for electronics components.  

相关型号:

ST72T251G2B6/XXX

8-Bit Microcontroller
ETC

ST72T251G2B6XXX

8-BIT, OTPROM, 8MHz, MICROCONTROLLER, PDIP32, 0.400 INCH, PLASTIC, SDIP-32
STMICROELECTR

ST72T251G2M3

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI, I2C AND 2 TIMERS
STMICROELECTR

ST72T251G2M3/XXX

8-Bit Microcontroller
ETC

ST72T251G2M3XXX

8-BIT, OTPROM, 4MHz, MICROCONTROLLER, PDSO28, 0.300 INCH, PLASTIC, SOIC-28
STMICROELECTR

ST72T251G2M6

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI, I2C AND 2 TIMERS
STMICROELECTR

ST72T251G2M6/XXX

8-Bit Microcontroller
ETC

ST72T251G2M6XXX

8-BIT, OTPROM, 8MHz, MICROCONTROLLER, PDSO28, 0.300 INCH, PLASTIC, SOIC-28
STMICROELECTR

ST72T2532R4T1

8-BIT MCU WITH NESTED INTERRUPTS, EEPROM, ADC, 16-BIT TIMERS, 8-BIT PWM ART, SPI, SCI, CAN INTERFACES
STMICROELECTR

ST72T2532R4T1S

8-BIT MCU WITH NESTED INTERRUPTS, EEPROM, ADC, 16-BIT TIMERS, 8-BIT PWM ART, SPI, SCI, CAN INTERFACES
STMICROELECTR

ST72T2532R4T3

8-BIT MCU WITH NESTED INTERRUPTS, EEPROM, ADC, 16-BIT TIMERS, 8-BIT PWM ART, SPI, SCI, CAN INTERFACES
STMICROELECTR

ST72T2532R4T3S

8-BIT MCU WITH NESTED INTERRUPTS, EEPROM, ADC, 16-BIT TIMERS, 8-BIT PWM ART, SPI, SCI, CAN INTERFACES
STMICROELECTR