Texas Instruments MSP50C6xx Calculator User Manual


 
C–– Efficiency
5-45Code Development Tools
; MAIN.CMM
; Revision 1.00
****************************************************************/
#include ram\ram.h
cmm_func goasm(); // an pseudo main asm routine
cmm_func getSecondsPassed(); // Retrieves the counter maintained
// by the Timer2 ISR and resets the
// counter.
intdays=0;
inthours=12;
intminutes=0;
int seconds=0;
intampm=0;
/************************************************
/ Updates time variables for clock ticks that
/ have occured.
************************************************/
cmm_func updateTime(){
seconds=seconds+getSecondsPassed();
while(seconds>59){
seconds=seconds60;
minutes++;
if(minutes>59){
minutes=0;
hours++;
if (hours == 12){
if(ampm==0){
ampm=1;
}
else{
ampm=0;
days++;
if(days>6){
days=0;
}//end days
}
}
if (hours>12){
hours=1;
}//end hours
}//end minutes
}//end seconds
}
cmm_func main()
{
goasm(); // run any assembly stuff that needs to be run
while(1){ // infinite loop
updateTime();
}
}
The include statement at the top of the program is for memory allocation
purposes. The C–– compiler is not aware that RAM has been allocated for
assembly and must be kept from overwriting it. This is done with an integer
array called bogus. The array is set to the size of the RAM allocated for