AN2616 Freescale Semiconductor / Motorola, AN2616 Datasheet - Page 26

no-image

AN2616

Manufacturer Part Number
AN2616
Description
Getting Started with HCS08 and CodeWarrior Using C
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2616
26
First, add an include statement to use our header file for the demo board:
Next, configure PORTF for output (LEDs) and PORTD for input (switches):
Code to turn on LED2 depending upon the state of SW2 would be:
To edit the main.c file, simply double-click on the file name within the project
window; this will invoke the file editor. By adding this code within the main
program, as illustrated below, LED2 will be turned on for as long as SW2 is
pressed. The resulting program is:
#include "M68DEMO908GB60.h"
LED2 = SW2;
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08GB60.h> /* include peripheral declarations */
#include "M68DEMO908GB60.h"
void main(void) {
}
Getting Started with HCS08 and CodeWarrior Using C
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;
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;
for(;;) {
} /* loop forever */
Freescale Semiconductor, Inc.
__RESET_WATCHDOG(); /* kicks the dog */
LED2 = SW2;
For More Information On This Product,
Go to: www.freescale.com
//initialize as input (Data Direction Register)
//initialize as input (Data Direction Register)
MOTOROLA

Related parts for AN2616