Interrupts- HCS12 - DragonBoard12+

Thread Starter

Lohitha Wickramasinghe

Joined Apr 20, 2017
3
I'm building a clock for 12 and 24 hour format. After setting the current time i need to run the clock. I need interrupt method to select either one of them. here is my way and can somebody tell me what I'm doing wrong? I use Codewarrior and C language. This is just part of the program that involves interrupts.

Code:
#include "C:\Users\Lohitha\Documents\Codewarrior Data\HCS12Utilities\hcs12.h"    
#include "C:\Users\Lohitha\Documents\Codewarrior Data\HCS12Utilities\delay.h"
     

void SetClk8(void);
void main(void) {


  SetClk8();
  //Enable Switches
  DDRH &= 0xF0; // Set PH0 through PH3 to input
  PIEH = 0x0F;  // Enable Interrupts on PH0,1, 2, and 3
  asm("cli");   // global setup
while(1);// wait here untill a push button is pushed

}


// -------------------------------------------------------------------
// This function enables PLL and use an 8-MHz crystal oscillator to
// generate 24-MHz E clock.
// -------------------------------------------------------------------
void SetClk8 (void) {
    SYNR    = 0x02; // set SYSCLK to 24 MHz from a 4-MHz oscillator
    REFDV   = 0;    //  " 
    PLLCTL  = 0x60; // turn on PLL, set automatic 
    while(!(CRGFLG & LOCK));
    CLKSEL  |= PLLSEL; // clock derived from PLL
}


interrupt void rtiISR(void){
   
    char value = PTH & 0x0F;
    PIFH |= 0xFF; //clear Port H flag
   
    if (value == 0x01) 
     {
      //If push button 0 is selected do this 
     } 
     else if (value == 0x02)
     {
       // If push button 1 is selected do this
     }
   
}
Also here is my vector.c file
Code:
extern void near rtiISR(void);
#pragma CODE_SEG __NEAR_SEG NON_BANKED

#pragma CODE_SEG DEFAULT               // Change code section to DEFAULT.

typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFFF2 = {
        rtiISR
};
 
Top