AN2616 Freescale Semiconductor / Motorola, AN2616 Datasheet - Page 30

no-image

AN2616

Manufacturer Part Number
AN2616
Description
Getting Started with HCS08 and CodeWarrior Using C
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2616
30
NOTE:
Add this code to the main program:
Do not forget to add the #define statement to the header file
M68DEMO908GB60.h.
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08GB60.h> /* include peripheral declarations */
#include "M68DEMO908GB60.h"
#define PRESCALAR 7
#define MODULUS 32768
#define DUTY75 (MODULUS-(MODULUS/4))
#define DUTY25 (MODULUS/4)
interrupt Vkeyboard void intSW1(){
}
void main(void) {
}
Getting Started with HCS08 and CodeWarrior Using C
EnableInterrupts; /* enable interrupts */
/* include your code here */
PTADD = 0;
PTAPE = 0xf0; //Pullups on upper 4 bits
/*initialize bits 0-3 of Port F as outputs (connected to led's)*/
PTFDD = 0x0f;
LED1 = OFF;
LED2 = OFF;
LED3 = OFF;
LED4 = OFF;
LED5 = OFF;
/*Initialize timer TPM1 channel, assumes not touched since reset!*/
TPM1SC_CLKSA = 1;/*Select BUS clock*/
TPM1SC_CLKSB = 0;
TPM1SC_PS = PRESCALAR;/*clock source divided by prescalar*/
TPM1MOD = MODULUS;/*set Counter modulus*/
/*configure PWM mode and pulse*/
TPM1C0SC_MS0B = 1;
TPM1C0SC_ELS0A = 1; /*Select low as true*/
TPM1C0V = DUTY25;/*select final divider (duty cycle)*/
LED4 = ON;
KBIPE_KBIPE4 = 1;
KBISC_KBIE = 1;
for(;;) {
} /* loop forever */
Freescale Semiconductor, Inc.
LED1 = SW4;
KBISC_KBACK = 1;/*acknowledge interrupt*/
__RESET_WATCHDOG(); /* kicks the dog */
LED2 = SW2;
if(SW3==DOWN){
}
For More Information On This Product,
/*Switch pressed*/
if(SW4==DOWN){/**/
}else{
}
TPM1C0V = DUTY25;/**/
TPM1C0V = DUTY75;/**/
LED3 = ON;/**/
LED4 = OFF;/**/
LED3 = OFF;/**/
LED4 = ON;/**/
Go to: www.freescale.com
//initialize as input (Data Direction Register)
/*MS0B=1, MS0A=0; << Edge align PWM*/
MOTOROLA

Related parts for AN2616