Subversion Repositories svnkaklik

Rev

Rev 6 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
 
2
/******************************************************************************
3
*       Copyright (C) 2005 Freescale Semiconductor, Inc.
4
*       All Rights Reserved
5
*
6
* Filename:     DEMO9S08QG8_Test.c
7
* Author:       r1aald
8
* Revision:     1.0
9
*
10
* Description:  This is the test code that will reside in the QG8 demo
11
*                to provide an out of the box experience. This simple code
12
*                blinks LED2 and toggles LED1 when SW1 is pressed.
13
*
14
* Notes:        Also serves as an example for the 9S08QG8 demo board.
15
*               Created using CodeWarrior 3.1 for HC(S)08.
16
******************************************************************************/
17
 
18
 
19
#include <hidef.h> /* for EnableInterrupts macro */
20
#include <MC9S08QG8.h> /* include peripheral declarations */
21
#include "demo9S08QG8.h" /*include demo board declarations */
22
 
23
 
24
void main(void) {
25
  EnableInterrupts; /* enable interrupts */
26
  /* include your code here */
27
 
28
        ICSC2_BDIV = 3;
29
        LED1 =0;
30
  LED2 =0;   //Port B7 is connected to LED 2
31
 
32
  PTBDD_PTBDD7 = 1; //Set PTB7 as an output
33
  PTBDD_PTBDD6 = 1;  		 
34
  //mtim_setup
35
  MTIMCLK_PS = 8;
36
  MTIMCLK_CLKS = 0;
37
  MTIMMOD = 112;
38
 
39
  MTIMMOD = 0;    //modulo = 50
40
  MTIMSC = 0x60;   //reset and start MTIM, enable ints
41
 
42
 //KBI Set Up foe SW1
43
 
44
 KBIPE_KBIPE2 =1; //Enable Keyboard Pin                                   
45
 KBISC_KBIE = 1;  //Enable Keyboard Interrupts
46
 KBISC_KBACK = 1; //Clear Pending Keyboard Interrupts
47
 PTAPE_PTAPE2 = 1; //Enable Pullup for Keyboard pin
48
 
49
 
50
  for(;;) {
51
    __RESET_WATCHDOG(); /* feeds the dog */
52
 
53
 
54
  } /* loop forever */
55
  /* please make sure that you never leave this function */
56
}
57
//KBI ISR
58
 interrupt 18 void   KBI_ISR(void) {
59
 KBISC_KBACK = 1; //Clear Pending Keyboard Interrupts
60
  LED1 = ~LED1;     // toggle Port
61
}
62
 
63
 
64
/* MTIM_ISR - ISR that accompanies the MTIM PWM routine. */
65
interrupt 12 void   MTIM_ISR(void) {
66
  MTIMSC_TOF=0;        // clear TOF
67
  LED2 = ~LED2;     // toggle Port
68
}
69