| |

|
#include <hidef.h> /* for
EnableInterrupts macro */
#include <MC68HC908GR4.h> /* include peripheral
declarations */
void wait_ms (int );
void set_bit (int , int );
void clear_bit(int , int );
void main(void) {
EnableInterrupts; /* enable interrupts */
/* include your code here */
set_bit (INT_RESET, 0xFF);
set_bit (COPCTL, 0xFF);
/* I/O port initialisation */
DDRA = 0x00;
DDRB = 0x00;
DDRC = 0x00;
DDRD = 0xFF; //Sets PORTD as Output
while(1){
wait_ms(100);
PTD_PTD4=1;
wait_ms(100);
PTD_PTD4=0;
}
}
/**********************************************\
/*************************************************\
Funtions
\*************************************************/
/***********************\
SET A BIT TO REGISTER
\***********************/
void set_bit(int addr, int bit)
{
int *t;
t = (int *)addr;
*t |= bit;
}
/***********************\
CLEAR BIT FROM REGISTER
\***********************/
void clear_bit(int addr, int bit)
{
int *t;
t = (int *)addr;
*t &= ~bit;
}
/***********************\
Wait in ms
\***********************/
void wait_ms(int value)
{
value=value*250 ;
while(value)value--;
}
|

|
|