File "interruption_type"

Full Path: /home/analogde/www/68hc11/interruption_type
File size: 1.79 KB
MIME-type: text/x-c
Charset: 8 bit

//--------------------------------------------------------------
#include <stdio.h>
#include "hcs12dp256.h"
//--------------------------------------------------------------
#pragma interrupt_handler isrOC2
void isrOC2(void) {
TFLG1 = 0x04; // clear OC2 Intr Flag
TC2 += 31250u; // 1 interrupt every 31250 timer ticks (0.5s)
PTH ^= 0x80; // toggle LED
}
//--------------------------------------------------------------
void main(void) {
// install OC2 pseudo vector in RAM
// (if running with TwinPEEKs monitor)
*((unsigned char *)0x3fe2) = 0x06; // JMP opcode
*((void (**)(void))0x3fe3) = isrOC2;
// make PTH[7] an Output to drive the LED
DDRH |= 0x80;
// Timer Setup
TSCR1 = 0x80; // Timer enable
TSCR2 = 0x07; // Prescaler = 128 (1 timer tick every 16s)
TCTL2 = 0x00; // TC2 disconnected from Pin
TIOS |= 0x04; // TC2 is Output Compare
TIE |= 0x04; // TC2 Interrupt enable
// enable Interrupts
asm("cli");
// loop endless (and let the interrupt work)
while(1) ;
}
//==============================================================


************************************************************
*                  Dbut du programme                      *
************************************************************
Debut	SEI			; set interrupt mask
		LDX  #base_reg		; X <--- $1000
		LDS  #$FF		; initialisation de la pile  FF

		BSET pactl,x,#0		; rti rate : 4,10 ms
		BSET tmsk2,x,#$40	; rti Interrupt Enable                   
...
***************************************************************
*   Dpart du programme  *
***************************************************************
		LDY  #introduction
		JSR  Aff_msg
...
B1		SEI
...
		JSR Lect_clavier
		JSR Aff_7seg
		CLI			; Clear interrupt Mask                 
		WAI			; Attente d'une interruption
		JMP  B1