//Frescale
HCS08 MC9S08DZ128
//Codewarrior
Development studio v 10.6
//Digital read and
write//bitwise
//12/3/2015
//written by Binu Kannur
#include <hidef.h> /* for
EnableInterrupts macro */
#include "derivative.h" /* include
peripheral declarations */
int sw;
void main(void)
{
// EnableInterrupts;
/*
include your code here */
PTBDD_PTBDD0=1;//set PortB data direction bit0 //output//PTxDD_PTxDDn
PTBDD_PTBDD2=1;//set PortB data direction bit2 //output //PTxDD_PTxDDn
PTDDD_PTDDD1=0;//set PortD data direction bit1 //Input //PTxDD_PTxDDn
for(;;)
{
__RESET_WATCHDOG(); /* feeds the dog */
if( PTDD_PTDD1==1)// check PortD bit1
is high?//connect aswitch
{
PTBD_PTBD0=1; //PortB bit0 high
PTBD_PTBD2=0; //PortB bit2 low
}
else if( PTDD_PTDD1==0)
{
PTBD_PTBD0=0;
PTBD_PTBD2=1;
}
}
}
///////////////////////////////////////
//PTADD=0; Port A
all input
//PTxPEn ---Pullup
enable
//0—disable
//1- enable
//PTxSEn=1 slew rate
enabled
//PTxSEn=0 slew
rate disabled
//PTxDSn----low drive
//PTxDSn=1---high
No comments:
Post a Comment