Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 13


 void start_response_delay_timer(void)
{
// This example sets a delay of around 0.5 second assuming FOSC = 4 MHz.


OpenTimer0( TIMER_INT_OFF &
T0_16BIT &
T0_SOURCE_INT &
T0_PS_1_256 );
WriteTimer0(0xf800);
}
The check_response_delay function finds out if the delay time has elapsed and
if so, changes the network_state variable to enable sending a response:

 check_response_delay:
if (delay_before_responding = 1) then


if (INTCON.2 = 1) then

' The delay time has elapsed.
' Stop the timer and set network_state to enable responding.

T0CON = 0
INTCON.2 = 0
network_state = "t"
endif
endif
return

 void check_response_delay(void)
{
#if defined(delay_before_responding)


if (INTCONbits.TMR0IF == 1)
{
// The delay time has elapsed.
// Stop the timer and set network_state to enable responding.

CloseTimer0;
INTCONbits.TMR0IF = 0;
network_state = 't';
}
#endif
}
Free download pdf