I have a simmilar problem but I don't want to use the output captures. I tried posting a
thread but it doesn't show up. Anyway, I plan to use a magnetic encoder and I'm making
sure I can receive a signal from a function generator on IC1 and IC2. I'm able to receive
an input on IC1 but on IC2, the terminal will show that the program is terminated the
moment I add an input to IC2. I'm guessing it's the vector addressing but I'm confused on
getting the right one even when I followed it. Here's the table and code:
http://www.freescale.com/files/microcontrollers/doc/data_sheet/M68HC11E.pdf
#include
#include
unsigned int old_TIC1;
unsigned int old_TIC2;
unsigned int period;
unsigned int period2;
unsigned long int frequency;
unsigned long int frequency2;
#pragma interrupt_handler icisr
#pragma interrupt_handler icisr2
void icisr(){
period = TIC1 - old_TIC1;
old_TIC1 = TIC1;
TFLG1 = 4;
}
void icisr2(){
period2 = TIC2 - old_TIC2;
old_TIC2 = TIC2;
TFLG1 = 2;
}
void initialization() {
*(unsigned char * )0xe8 = 0x7e;
*(void(**)())0xe9 = icisr;
*(unsigned char * )0xec = 0x7e; //I'm unsure of ec & ed
*(void(**)())0xed = icisr2;
TMSK1 = 6;
TCTL2 = 0x14; /* configure to capture rising edge of IC1 & IC2*/
asm("cli\n");
}
void calculate(){
frequency = 2000000/period;
frequency2 = 2000000/period2;
}
void output(){
printf("Frequency = %ld Hz, Period = %d.%d microseconds. ",
frequency,period/2,(period%2)*5);
printf("Frequency2 = %ld Hz, Period2 = %d.%d microseconds\r", frequency2,(period2)/2,
(period2%2)*5);
}
void main(){
initialization();
while(1){
calculate();
output();}
}
------------------------------------

(You need to be a member of hc11 -- send a blank email to hc11-subscribe@yahoogroups.com )