// filename COP12.C // add this file so that handle COP // COP reset could have been disabled by writing COPCTL=0; // In this module however, COP is active // Consequently, this module will create a TOF thread // to keep the active COP from generating a COP reset // Last modified 8/17/00 by Jonathan W. Valvano // Copyright 2000 by Jonathan W. Valvano, valvano@uts.cc.utexas.edu // You may use, edit, run or distribute this file // as long as the above copyright notice remains //******** TOFhandler *************** // called when TCNT rolls over from $FFFF to 0 // at 500ns counting, interrupts every 32ms #pragma interrupt_handler TOFhandler void TOFhandler(void){ TFLG2=0x80; // TOF interrupt acknowledge PORTT^=0x40; // toggle bit 6 COPRST=0x55; // make COP happy COPRST=0xAA; } #pragma abs_address:0xffde void (*TOF_vector[])() = { TOFhandler }; #pragma end_abs_address //******** COPinit *************** // Initialize TOF interrupts, enable timer, // make PT6 an output, and enable interrupts void COPinit(void){ DDRT |=0x40; // PortT bit 6 is output TSCR =0x80; // TCNT enable, TEN=1 TMSK2=0xA2; // TOI arm, TPU(pullup) timer/4 (500ns) CLKCTL=0x00; asm(" cli"); // background TOF thread to keep COP happy }