Subversion Repositories svnkaklik

Rev

Rev 409 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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