Code: /* Including used modules for compiling procedure */ #include "Cpu.h" #include "Events.h" #include "Got_Bit_Interrupt.h" #include "High.h" /* Include shared modules, which are used for whole project */ #include "PE_Types.h" #include "PE_Error.h" #include "PE_Const.h" #include "IO_Map.h" #include "RUNEXTERN.h"
/********************************************************************************** ** DECLARATIONS ** *********************************************************************************/ void sciInit(void); void sendSCI(void); void decoder(void);
/********************************************************************************** ** GLOBAL VARIABLES ** *********************************************************************************/ int count; byte temp; byte toSerial; byte arrayMask[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
/********************************************************************************** ** MAIN ** *********************************************************************************/ void main(void){
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/
Cpu_DisableInt(); sciInit(); Cpu_EnableInt(); decoder();
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/********************************************************************************** ** SCI FUNCTIONS ** *********************************************************************************/
void sciInit(void){ SOPT1 = 0x10; SCIBD = 26; SCIC2 = 0x08; } void sendSCI(void){ while(!SCIS1_TDRE); SCID = toSerial; decoder(); }
/********************************************************************************** ** DECODER FUNCTIONS ** *********************************************************************************/
/** This encodes zeros and ones as hi and creates an encoded 'clock pulse' * allowing rf reciever to send data correctly */
void decoder(void){ maskNum = 0; toSerial = 0; while(maskNum < 8); for(count = 0; count < 8; count++){ temp = (bits[count] & arrayMask[count]); toSerial |= temp; } sendSCI(); }
|