C– – Efficiency

Seven of the files are important to the functionality of this project. The Timer2 ISR (tim2_isr.asm) forms the basis for the RTC so it will be discussed first.

timer2_isr

mov *save_tim2_stat,STAT ;save status

mov *save_tim2_a0,a0 ;save a0

;timer fired so 1 second passed

;update the variable storing the seconds passed so far mov a0, *seconds_passed

add a0, a0, 1

mov *seconds_passed, a0

mov a0,*save_tim2_a0 ;restore a0

mov STAT,*save_tim2_stat

;restore status

inte

;turn interrupts back on

iret

The Timer2 ISR is configured to fire at 1 second intervals. Each time the ISR executes, it saves any registers that it will modify, increments the RAM location seconds_passed, and restores the registers it modified.

The second important file is main_ram.irx. It is used to allocate RAM for seconds_passed and for saving and restoring registers in the Timer2 ISR.

;****************************************************************

;MAIN_RAM.IRX

;Start of memory for MAIN module is defined in

;include ”..\ram\ram.irx” ;****************************************************************

;Timer 2 interrupt variables

save_tim2_stat

equ RAMSTART_CUSTOMER + 2 * 1

save_tim2_a0

equ save_tim2_stat + 2 * 1

seconds_passed

equ save_tim2_a0 + 2 * 1

RAMSTART_CMM1

equ seconds_passed

include ”cmm1_ram.irx”

; End of RAM

 

RAMEND_CUSTOMER

equ RAMEND_CMM1

RAMLENGTH_CUSTOMER equ RAMEND_CUSTOMER – RAMSTART_CUSTOMER

 

Any additional ram that is used in an ISR or in mainasm.asm should be

 

allocated here. RAM is allocated by making a new label and setting it equal to

 

the previous label plus an offset. A variable called some_variable could be

 

allocated by changing

seconds_passed

equ save_tim2_a0 + 2 * 1

RAMSTART_CMM1

equ seconds_passed

 

to

seconds_passed

equ save_tim2_a0 + 2 * 1

some_variable

equ seconds_passed + 2 * 1

RAMSTART_CMM1

equ some_variable

 

The next important file is vroncof2.asm. Most of this file is used to support

 

standard C functionality and will not need to be changed. The part that will

Code Development Tools

5-41

Page 337
Image 337
Texas Instruments MSP50C6xx manual Allocated by changing, Mainram.Irx