Page 328 - Programming Microcontrollers in C
P. 328
Cosmic MC68HC16 Compiler 313
been_here=OFF;
output_time();
}
}
}
void output_time(void)
{
int i;
putch(‘\r’); /* send out a carriage return */
putch(‘\t’);
putch(‘\t’); /* tab over the pwm_count */
putch(‘\t’); /* on the screen */
send_out(hrs);
putch(‘:’);
send_out(mts);
putch(‘:’);
send_out(sec);
putch(‘\r’);
}
void putch(int x)
{
while(SCSR.TDRE==OFF)
; /* wait until data
register is empty*/
SCDR = (char) x;
}
void send_out(WORD data)
{
putch(get_hi(data));
putch(get_lo(data));
}
/* The asynchronous service portion of the program */
@port void OC3_Isr( void) /* the PWM isr */
{
TFLG1.OC1F=OFF; /* reset OC1 interrupt flag */
if(OC1D.OC1D3==ON)
OC1D.OC1D3=OFF;
else
OC1D.OC1D3=ON;
TFLG1.OC3F=OFF; /* reset OC3 interrupt flag */
TOC1+=pwm_period;