Creating 2 input captures

Discussion in 'Embedded Systems and Microcontrollers' started by factorial555, May 1, 2009.

  1. factorial555

    Thread Starter New Member

    Apr 18, 2009
    I have some trouble creating 2 input captures on a 68HC11 microcontroller board. I can get a signal from PA2/IC1 however, I'm unable to get a signal from PA1/IC2. Whenever I input a signal into IC2, my program terminates. I've looked at my book and examples but I don't see one with 2 input captures. Any help would be appreciated. My code below:

    #include <hc11.h>
    #include <stdio.h>
    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

    void icisr(){
    period = TIC1 - old_TIC1;
    old_TIC1 = TIC1;
    period2 = TIC2 - old_TIC2;
    old_TIC2 = TIC2;
    TFLG1 = 6;

    void initialization() {
    *(unsigned char * )0xe8 = 0x7e;
    *(void(**)())0xe9 = icisr;
    TMSK1 = 6; /* enable IC1 & IC2 */
    TCTL2 = 0x14; /* configure to capture rising edge of IC1 & IC2*/

    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(){