1 /** ###################################################################
\r
2 ** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
\r
4 ** Project : RTOSDemo
\r
5 ** Processor : MC9S12C32CFU
\r
6 ** Beantype : MC9S12C32_80
\r
7 ** Version : Bean 01.002, Driver 01.09, CPU db: 2.87.276
\r
8 ** Compiler : Metrowerks HC12 C Compiler
\r
9 ** Date/Time : 18/06/2005, 18:00
\r
11 ** This bean "MC9S12C32_80" implements properties, methods,
\r
12 ** and events of the CPU.
\r
16 ** EnableInt - void Cpu_EnableInt(void);
\r
17 ** DisableInt - void Cpu_DisableInt(void);
\r
18 ** SetWaitMode - void Cpu_SetWaitMode(void);
\r
19 ** SetStopMode - void Cpu_SetStopMode(void);
\r
21 ** (c) Copyright UNIS, spol. s r.o. 1997-2002
\r
22 ** UNIS, spol. s r.o.
\r
26 ** http : www.processorexpert.com
\r
27 ** mail : info@processorexpert.com
\r
28 ** ###################################################################*/
\r
33 #include "TickTimer.h"
\r
34 #include "ButtonInterrupt.h"
\r
35 #include "PE_Types.h"
\r
36 #include "PE_Error.h"
\r
37 #include "PE_Const.h"
\r
39 #include "PE_Timer.h"
\r
43 #define CGM_DELAY 3071UL
\r
46 /* Global variables */
\r
47 volatile byte CCR_reg; /* Current CCR reegister */
\r
48 byte CpuMode = HIGH_SPEED; /* Current speed mode */
\r
52 ** ===================================================================
\r
53 ** Method : Cpu_Interrupt (bean MC9S12C32_80)
\r
56 ** This method is internal. It is used by Processor Expert
\r
58 ** ===================================================================
\r
60 #pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */
\r
62 __interrupt void Cpu_Interrupt(void)
\r
66 #pragma CODE_SEG DEFAULT /* Change code section to DEFAULT. */
\r
69 ** ===================================================================
\r
70 ** Method : Cpu_DisableInt (bean MC9S12C32_80)
\r
73 ** Disable maskable interrupts
\r
74 ** Parameters : None
\r
75 ** Returns : Nothing
\r
76 ** ===================================================================
\r
79 void Cpu_DisableInt(void)
\r
81 ** This method is implemented as macro in the header module. **
\r
85 ** ===================================================================
\r
86 ** Method : Cpu_EnableInt (bean MC9S12C32_80)
\r
89 ** Enable maskable interrupts
\r
90 ** Parameters : None
\r
91 ** Returns : Nothing
\r
92 ** ===================================================================
\r
95 void Cpu_EnableInt(void)
\r
97 ** This method is implemented as macro in the header module. **
\r
101 ** ===================================================================
\r
102 ** Method : Cpu_SetStopMode (bean MC9S12C32_80)
\r
105 ** Set low power mode - Stop mode. For more information
\r
106 ** about the stop mode see documentation of this CPU.
\r
107 ** Parameters : None
\r
108 ** Returns : Nothing
\r
109 ** ===================================================================
\r
112 void Cpu_SetStopMode(void)
\r
114 ** This method is implemented as macro in the header module. **
\r
118 ** ===================================================================
\r
119 ** Method : Cpu_SetWaitMode (bean MC9S12C32_80)
\r
122 ** Set low power mode - Wait mode. For more information
\r
123 ** about the wait mode see documentation of this CPU.
\r
124 ** Release from Watch mode: Reset or interrupt
\r
125 ** Parameters : None
\r
126 ** Returns : Nothing
\r
127 ** ===================================================================
\r
130 void Cpu_SetWaitMode(void)
\r
132 ** This method is implemented as macro in the header module. **
\r
136 ** ===================================================================
\r
137 ** Method : _EntryPoint (bean MC9S12C32_80)
\r
140 ** This method is internal. It is used by Processor Expert
\r
142 ** ===================================================================
\r
144 extern void _Startup(void); /* Forward declaration of external startup function declared in file Start12.c */
\r
145 #define INITRG_ADR 0x0011 /* Register map position register */
\r
148 void _EntryPoint(void)
\r
150 /*** ### MC9S12C32_80 "Cpu" init code ... ***/
\r
151 /*** PE initialization code after reset ***/
\r
152 /* Initialization of the registers INITRG, INITRM, INITEE is done to protect them to be written accidentally later by the application */
\r
153 *(byte*)INITRG_ADR = 0; /* Set the register map position */
\r
154 asm nop; /* nop instruction */
\r
155 INITRM=8; /* Set the RAM map position */
\r
156 /* MISC: ??=0,??=0,??=0,??=0,EXSTR1=0,EXSTR0=0,ROMHM=0,ROMON=1 */
\r
158 /* System clock initialization */
\r
160 CLKSEL_PLLSEL = 0; /* Select clock source from XTAL */
\r
161 PLLCTL_PLLON = 0; /* Disable the PLL */
\r
162 SYNR = 23; /* Set the multiplier register */
\r
163 REFDV = 15; /* Set the divider register */
\r
165 PLLCTL_PLLON = 1; /* Enable the PLL */
\r
166 while(!CRGFLG_LOCK); /* Wait */
\r
167 CLKSEL_PLLSEL = 1; /* Select clock source from PLL */
\r
168 /*** End of PE initialization code after reset ***/
\r
170 __asm jmp _Startup; /* Jump to C startup code */
\r
174 ** ===================================================================
\r
175 ** Method : PE_low_level_init (bean MC9S12C32_80)
\r
178 ** This method is internal. It is used by Processor Expert
\r
180 ** ===================================================================
\r
182 void PE_low_level_init(void)
\r
184 /* Common initialization of the CPU registers */
\r
185 /* TSCR1: TEN=0,TSWAI=0,TSFRZ=1 */
\r
186 output( TSCR1, input( TSCR1 ) & ~192 | 32 );
\r
187 /* TCTL2: OM0=0,OL0=0 */
\r
188 output( TCTL2, input( TCTL2 ) & ~3 );
\r
189 /* TCTL1: OM7=0,OL7=0 */
\r
190 output( TCTL1, input( TCTL1 ) & ~192 );
\r
192 output( TIE, input( TIE ) & ~1 );
\r
194 output( TTOV, input( TTOV ) & ~1 );
\r
195 /* TSCR2: TOI=0,TCRE=1 */
\r
196 output( TSCR2, input( TSCR2 ) & ~128 | 8 );
\r
197 /* TIOS: IOS7=1,IOS0=1 */
\r
198 output( TIOS, input( TIOS ) | 129 );
\r
199 /* PPSP: PPSP0=0 */
\r
200 output( PPSP, input( PPSP ) & ~1 );
\r
201 /* PERP: PERP0=1 */
\r
202 output( PERP, input( PERP ) | 1 );
\r
203 /* DDRP: DDRP0=0 */
\r
204 output( DDRP, input( DDRP ) & ~1 );
\r
205 /* PWMCTL: PSWAI=0,PFRZ=0 */
\r
206 output( PWMCTL, input( PWMCTL ) & ~12 );
\r
207 /* PWMSDN: PWMIF=0,PWMIE=0,PWMRSTRT=0,PWMLVL=0,??=0,PWM7IN=0,PWM7INL=0,PWM7ENA=0 */
\r
208 output( PWMSDN, 0 );
\r
209 /* ### MC9S12C32_80 "Cpu" init code ... */
\r
210 /* ### ByteIO "Byte1" init code ... */
\r
211 PORTB = 0; /* Prepare value for output */
\r
212 DDRB = 255; /* Set direction to output */
\r
213 /* ### TimerInt "TickTimer" init code ... */
\r
215 /* ### External interrupt "ButtonInterrupt" init code ... */
\r
216 PIEP_PIEP0 = 0; /* Disable interrupt */
\r
217 /* Common peripheral initialization - ENABLE */
\r
219 output( TSCR1, input( TSCR1 ) | 128 );
\r
220 INTCR_IRQEN = 0; /* Disable the IRQ interrupt. IRQ interrupt is enabled after CPU reset by default. */
\r
221 __DI(); /* Disable interrupts */
\r
227 ** ###################################################################
\r
229 ** This file was created by UNIS Processor Expert 03.33 for
\r
230 ** the Motorola HCS12 series of microcontrollers.
\r
232 ** ###################################################################
\r