beautypg.com

3 interrupts, 4 timers, Nterrupts – Maxim Integrated Secure Microcontroller User Manual

Page 90: Imers

background image

Secure Microcontroller User’s Guide

90 of 187

the Partition is set to 5800h, the DPTR should be set to 5800h to start. Once data has been saved in NV
RAM, the DPTR should be saved in a known, nonvolatile location so that is can be restored on a reset.

10.3 Interrupts

All interrupts are disabled after a reset so the user must enable individual interrupts as needed, as well as
the global interrupt. Any interrupt needing a higher priority must be selected as such. The following code
example shows the enabling of individual interrupts. A user would combine the appropriate bits as needed
by the application. In this application example, the serial port is given a high priority interrupt.

ORG

00h

SJMP

Start


Org

30h


Start :

ORL

PCON,

#08h

;Enable Power–fail Warning by setting EPFW

SETB

PS

;Set Serial Port Interrupt to High Priority

SETB

ES

;Enable Serial Port Interrupt

SETB

ET1

;Enable Timer 1 Interrupt

SETB

EX1

;Enable External Interrupt 1

SETB

ET0

;Enable Timer 0 Interrupt

SETB

EX0

;Enable External Interrupt 0

SETB

EA

; Globally enable interrupts

10.4 Timers

The microprocessor disables timer activity (excluding the Watchdog) and serial port communication on a
reset. Therefore, each timer (and serial port, if used) must be reinitialized as part of the reset routine. This
is covered in detail in the User’s Guide section on Timers and Serial I/O respectively. Shown here is an
example of Timer and Serial Port setup. In this example, Timer 0 is set up to generate a 10ms interrupt.
Timer 1 is setup to generate 9600 baud for the serial port. The serial port is set up for asynchronous
communication with a PC (mode 1). A crystal frequency of 11.0592MHz is assumed.

ORG

00h

SJMP

Start


Org

30h


Start :

SETB

PS

;Set Serial Port Interrupt to High Priority

SETB

ES

;Enable Serial Port Interrupt

SETB

ET0

;Enable Timer 0 Interrupt

MOV

TMO,

#00100001b ;Select Timer 1 mode 2 – 8 bit auto–reload,

; Timer 0 mode 1 – 16 bit manual reload

MOV

TH1,

#0FDh

;Setup 9600 baud

MOV

TL1,

#00h

; ” ”

MOV

TH0,

#0DBh

;Select a 10 ms count. 9216 counts = 10 ms

MOV

TL0,

#0FFh

; 9216d counts = 2400h counts (FFFFh–2400h =

; DBFFh)

; Timer 0 ISR must reload DBFFh manually

MOV

SCON,

#01010011b ;Select Serial Port mode 1,

; TXD and RXD interrupts active

MOV

TCON,

#01010000b ;Enable the operation of both Timers

SETB

EA

;Globally enable interrupts