Subversion Repositories svnkaklik

Rev

Go to most recent revision | Blame | Last modification | View Log | Download


/******************************************************************************
*       Copyright (C) 2005 Freescale Semiconductor, Inc.
*       All Rights Reserved
*
* Filename:     DEMO9S08QG8_Test.c
* Author:       r1aald
* Revision:     1.0
*
* Description:  This is the test code that will reside in the QG8 demo
*                to provide an out of the box experience. This simple code
*                blinks LED2 and toggles LED1 when SW1 is pressed.
*
* Notes:        Also serves as an example for the 9S08QG8 demo board.
*               Created using CodeWarrior 3.1 for HC(S)08.
******************************************************************************/


#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08QG8.h> /* include peripheral declarations */
#include "demo9S08QG8.h" /*include demo board declarations */
         

void main(void) {
  EnableInterrupts; /* enable interrupts */
  /* include your code here */
  
        ICSC2_BDIV = 3;
        LED1 =0;
  LED2 =0;   //Port B7 is connected to LED 2
  
  PTBDD_PTBDD7 = 1; //Set PTB7 as an output
  PTBDD_PTBDD6 = 1;              
  //mtim_setup
  MTIMCLK_PS = 8;
  MTIMCLK_CLKS = 0;
  MTIMMOD = 112;
  
  MTIMMOD = 0;    //modulo = 50
  MTIMSC = 0x60;   //reset and start MTIM, enable ints
  
 //KBI Set Up foe SW1
 
 KBIPE_KBIPE2 =1; //Enable Keyboard Pin                                   
 KBISC_KBIE = 1;  //Enable Keyboard Interrupts
 KBISC_KBACK = 1; //Clear Pending Keyboard Interrupts
 PTAPE_PTAPE2 = 1; //Enable Pullup for Keyboard pin
             
  
  for(;;) {
    __RESET_WATCHDOG(); /* feeds the dog */
    
    
  } /* loop forever */
  /* please make sure that you never leave this function */
}
//KBI ISR
 interrupt 18 void   KBI_ISR(void) {
 KBISC_KBACK = 1; //Clear Pending Keyboard Interrupts
  LED1 = ~LED1;     // toggle Port
}


/* MTIM_ISR - ISR that accompanies the MTIM PWM routine. */
interrupt 12 void   MTIM_ISR(void) {
  MTIMSC_TOF=0;        // clear TOF
  LED2 = ~LED2;     // toggle Port
}