AN2616 Freescale Semiconductor / Motorola, AN2616 Datasheet - Page 28
![no-image](/images/no-image-200.jpg)
AN2616
Manufacturer Part Number
AN2616
Description
Getting Started with HCS08 and CodeWarrior Using C
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
1.AN2616.pdf
(62 pages)
- Current page: 28 of 62
- Download datasheet (2Mb)
AN2616
Use PWM to flash
LED
28
Adding the following code to the program will configure the PWM and will flash
LED5 (or buzzer on evaluation board), using LED3 and LED4 to indicate the
duty cycle selected by switch SW4, when changed by the operation of switch
SW3.
#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)
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;
for(;;) {
} /* loop forever */
Freescale Semiconductor, Inc.
__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
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
![AN177](/images/no-image3.png)
Part Number:
Description:
An Overview og the Phase Locked Loop
Manufacturer:
Philips
Datasheet:
![AN1268](/images/manufacturer_photos/0/6/637/stmicroelectronics_tmb.jpg)
Part Number:
Description:
AN OVERVIEW OF THE LPC FLASH INTERFACE
Manufacturer:
STMicroelectronics
![AN1315](/images/no-image3.png)
Part Number:
Description:
An Evaluation System Interfacing the MPX2000 Series Pressure Sensors to a Microprocessor
Manufacturer:
Motorola / Freescale Semiconductor
![AN1998](/images/no-image3.png)
Part Number:
Description:
An FM-IF system for DECT and other high speed GFSK applications
Manufacturer:
Philips Semiconductors / NXP Semiconductors
![AN2124](/images/no-image3.png)
Part Number:
Description:
An 8 x 8 Discrete Cosine Transform on the StarCore SC140/SC1400 Cores
Manufacturer:
Freescale Semiconductor / Motorola
![AN2428](/images/no-image3.png)
Part Number:
Description:
An Overview of the HCS12 ATD Module
Manufacturer:
Freescale Semiconductor / Motorola
![AN2708](/images/no-image3.png)
Part Number:
Description:
An Introduction to the External Bus Interface on the HCS12X
Manufacturer:
Freescale Semiconductor / Motorola
![AN2783](/images/no-image3.png)
Part Number:
Description:
An RF Data Link Using Tango3 and Romeo2 RF Modules
Manufacturer:
Freescale Semiconductor / Motorola
![MC33394DH](/images/manufacturer_photos/0/2/262/freescale_semiconductor_tmb.jpg)
Part Number:
Description:
IC POWER SUPPLY MULT-OUT 44-HSOP
Manufacturer:
Freescale Semiconductor
Datasheet:
![MC33394DWB](/images/manufacturer_photos/0/2/262/freescale_semiconductor_tmb.jpg)
Part Number:
Description:
IC POWER SUPPLY MULT-OUT 54-SOIC
Manufacturer:
Freescale Semiconductor
Datasheet:
![MSC7110](/images/no-image3.png)
Part Number:
Description:
Low-Cost 16-Bit DSP with DDR Controller
Manufacturer:
Freescale Semiconductor / Motorola
![MSC7116](/images/no-image3.png)
Part Number:
Description:
Low-Cost 16-bit DSP with DDR Controller and 10/100 Mbps Ethernet MAC
Manufacturer:
Freescale Semiconductor / Motorola
Datasheet:
![MSC7119](/images/no-image3.png)
Part Number:
Description:
Low-Cost 16-bit DSP with DDR Controller and 10/100 Mbps Ethernet MAC
Manufacturer:
Freescale Semiconductor / Motorola
Datasheet:
![MSC7118](/images/no-image3.png)
Part Number:
Description:
Low-Cost 16-bit DSP with DDR Controller
Manufacturer:
Freescale Semiconductor / Motorola
Datasheet:
![MSC8101](/images/no-image3.png)
Part Number:
Description:
Functional Pin Difference Between the MSC8101 and MPC8260 Communications Processor Modules
Manufacturer:
Freescale Semiconductor / Motorola