Sie sind auf Seite 1von 2

#include <hidef.

h> /* for EnableInterrupts macro */


#include "derivative.h" /* include peripheral declarations */
unsigned char *data;
unsigned char size;

void PLL_Init(void)
{
MCGC1 = 0x98; //clock Divider = 8
MCGC2 = 0x37;
MCGC3 = 0x44; //Bus freq = 25 MHz
while(!MCGSC_OSCINIT)
{
__RESET_WATCHDOG();
}
MCGC1 = 0x18;
while(!MCGSC_LOCK)
{
__RESET_WATCHDOG();
}
}
void SCI2_init(void)
{
SCI2BD =27;
SCI2C1 =0;
SCI2S1 = ; //Status borra banderas
SCI2C2 = 0b01101100;
PTDPF1 = 0b10100000;
}
void SCI2_Transmit (unsigned char *data, unsigned char size) {
Dataptr=data;
DataCnt=size; //data counter
SCI2C2_TCIE=1;
serial2status|(1<<0);
}
interrupt xx void Tx_ISR(void){
SCI2C1;
if(DataCnt != 0){
DataCnt--;
SCI2D=*Datptr++;
}else{
SCI2C2_TCIE=0;
serialstatus &=~(1<<0);
}
}
interrupt yy void Rx_ISR(void){
SCI2C1;
if(index==100){ //buffer circular
index=0;
}
bufferRx[index++]=SCI2D;
serialstatus|(1<<1)
}
void main(void) {
PTDD=0b1000000;
ADCSC1=0x03;
ADCCFG=0xC0;

PLL_Init();

EnableInterrupts; /* enable interrupts */


/* include your code here */

for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave main */
}

Das könnte Ihnen auch gefallen