Program fragment using the Computer Operating Properly interrupt


#include <hc11.h>

/* Use of COP -- assumes NOCOP bit is 0 in CONFIG register     *
 * Can only change NOCOP bit by writing EEPROM CONFIG register *
 * If proper action not taken, get COP Failure interrupt, with *
 * interrupt vector FFFA-FFFB                                  */

main()
{
    OPTION = 3;    /* COP timer times out in 1.049 seconds */

	/* Set up COP  interrupt vector */

	while(1)
	{
	    .
		.
		.
		COPRST = 0x55;   /* Must write 0x55 followed by 0xAA before */
		COPRST = 0xAA;   /* COP timer times out to reset timer      */
	}
}
	
#pragma interrupt_handler cop_isr

void cop_isr(void)
{
    /* Code to deal with program failure */
}