Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
68hc11
/
68HC12
:
timer.C
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
http://www.embeddedlearningcenter.com/scripts/tol.exe?SID,13586.16802.20040716&CONFIG,pc-freescale.txt&TEMPLATE,pc_main.ops&AREA,8&COURSE,24570 void main (void) { KBIER |= 0x5; /* Enable KBI0 and KBI2 IRQs */ EnableInterrupts; /* main loop goes here */ } interrupt 15 void MyFirstKeyboardInterrupt (void) { KBSCR |= 0x04; /* Ack this interrupt */ /* Do your stuff here */ } void main (void) { KBIER |= 0x5; /* Enable KBI0 and KBI2 IRQs */ EnableInterrupts; /* main loop goes here */ } To simply test your Interrupt handing you can use the simulator and write a handler to populate and process the Software Interrupt. Here is the example; interrupt 1 void MySoftwareInterrupt (void) { __asm ( "nop" ); /* Place your breakpoint here */ } /********************************************************************************************************/ #include "hidef.h" #define COUNT 75 /* Interrupts per sec */ unsigned char cCounter=0x00; /* Interrupt Events Counter */ void main(void) { CONFIG1 = 0x0B; /* COP dis, STOP En, LVI En @5v */ CONFIG2 = 0x03; /* SCI using Int Clk, Osc En @STOP */ DDRC = 0xFF; /* Configure PortC as Output */ PORTC = 0xFF; /* Initialize PortC */ TBCR = 0x04; /* Configure TimeBase Status & Control Reg TBM OFF & interrupt enabled Select Timebase Rate (Div 2^15) @XTAL=4.9152MHz -> Freq=150Hz */ cCounter = COUNT; /* Initialize the Counter */ EnableInterrupts; TBCR |= TBON /* Turn TBM on */ while(1); }/* END main() */ interrupt 17 void TBM_ISR (void){ TBCR |= TACK; /* TimeBase Interrupt Acknowledge */ if( !(--cCounter) ){ /* If Counter is ZERO then */ PORTC = ~PORTC; /* Toggle LED */ cCounter = COUNT; /* Reinitialize the Counter */ } }/* END TBM_ISR() */ /*******************************************************************/ EnableInterrupts;