Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
private
/
Projet
/
Example
/
HC11
:
iexample.c
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/*============================================================================ Motorola 68HC11 Demonstrate assigning timer interrupt handler at run time under monitor program as well as in rom mode. Author: Dusty Nidey, Axiom Mfg. Tools: ImageCraft C Compiler V3.5 ==============================================================================*/ #include <hc11.h> // Constants // Definitions unsigned char count4; // general purpose count byte unsigned char timeout1; // general purpose timeout. incriments every .03277 seconds // these functions only used for debugging in Buffalo Monitor // they can be safely removed for production, or left in void break1(){ asm("bh1: nop"); } /* TimeHandle - Interrupt Handler routine Gets executed on Timer1 overflow flag, which is set to default prescaler of over 32.77ms */ #pragma interrupt_handler TimeHandle void TimeHandle(){ TFLG2 = 0x80; // clear timer overflow flag // if timer overflow. // here every 32.77ms or .03277 seconds ++timeout1; // incriment timeout counter if(rtimeout < R_TIMEOUT) ++rtimeout; // incriment timeout counter if(++count4 > 15){ // if time to update counters // here every .49155 seconds count4=0; } } /* RESET - MAIN After executing STARTUP code on reset, execution begins here */ main(){ asm(" sei"); // disable interrupts // FOR BUFFALO MODE ONLY - setup pseudo-interrupt vectors, uncomment this // For EEPROM mode, use the interrupt vectors table at the end of this file // *(void(**)())0xD1 = TimeHandle; // Timer Overflow $00DO-$00D2 TCTL2 = 0x06; // enable input capture for A0 and A1 TFLG1 = 0x01; // clear input capture flag - IDLE TMSK2 = 0x80; // enable timer interrupts TFLG2 = 0x80; // clear timer overflow flag asm(" cli"); // enable interrupts // reset all counters count4=0; // MAIN LOOP begins .. endless for( ; ;){ } } // Buffalo Debugger routine to send a HEX formatted byte to the COM1 terminal void sendbyte(unsigned char byt4){ dummy1 = byt4; asm(" ldaa _dummy1"); asm(" jsr 0xFFB2"); asm(" ldaa _dummy1"); asm(" jsr 0xFFB5"); } /*---------------------------------------------------------------- */ /* REMOVE the following if running this under the Buffalo Debugger */ extern void _start(); /* entry point in crt11.s */ #pragma abs_address:0xffd6 /* change the above address if your vector starts elsewhere */ void (*interrupt_vectors[])() = { /* to cast a constant, say 0xb600, use (void (*)())0xb600 */ /* all interrupts reset the processor, which is probably not what * you want */ _start, /* SCI */ _start, /* SPI */ _start, /* PAIE */ _start, /* PAO */ TimeHandle, /* TOF */ _start, /* TOC5 */ _start, /* TOC4 */ _start, /* TOC3 */ _start, /* TOC2 */ _start, /* TOC1 */ _start, /* TIC3 */ _start, /* TIC2 */ _start, /* TIC1 */ _start, /* RTI */ _start, /* IRQ */ _start, /* XIRQ */ _start, /* SWI */ _start, /* ILLOP */ _start, /* COP */ _start, /* CLM */ _start /* RESET */ }; #pragma end_abs_address