Code:
#include "SerialPort.h"unsigned char getStr[250] = "";unsigned char iStr;#pragma CODE_SEG __NEAR_SEG NON_BANKEDISR(ReceiveInterrupt){ unsigned char Temp, received_byte; Temp = SCI0SR1; // Acknowledge Receiver Full Flag received_byte = SCI0DRL; getStr[iStr] = received_byte; if(iStr == 250) iStr = 0; else iStr++; /* while (!SCI0SR1_TDRE); // Wait for the transmit buffer to be empty SCI0DRL = received_byte; // Send back the result */}#pragma CODE_SEG DEFAULT/*** ===================================================================** Method : SerialPort_Init (bean Init_SCI)**** Description :** This method initializes registers of the SCI module** according to this Peripheral Initialization Bean settings.** Call this method in user code to initialize the module.** By default, the method is called by PE automatically; see** "Call Init method" property of the bean for more details.** Parameters : None** Returns : Nothing** ===================================================================*/void SerialPort_Init(void){ /* SCI0SR2: —–=0,˜™=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */ setReg8(SCI0SR2, 0); /* SCI0BD: IREN=0,TNP1=0,TNP0=1,SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=0,SBR6=0,SBR5=1,SBR4=1,SBR3=0,SBR2=1,SBR1=0,SBR0=0 */ setReg16(SCI0BD, 52); /* SCI0CR1: LOOPS=0,SCISWAI=0,Rsrc=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */ setReg8(SCI0CR1, 0); /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */ setReg8(SCI0CR2, 44); }/* END SerialPort. *//**********MAIN Code****************************//* Including used modules for compiling procedure */#include "Cpu.h"#include "Events.h"#include "GreenLed.h"#include "SerialPort.h"#include "TI1.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"unsigned char str[] = "Test Serial Port Send Data";unsigned char i;void main(void){ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ for(i=0; i<26 ; i++){ while (!SCI0SR1_TDRE); // Wait for the transmit buffer to be empty SCI0DRL = str[i]; // Send back the result } /*while(1){ while (!SCI0SR1_TDRE); // Wait for the transmit buffer to be empty SCI0DRL = 'U'; // Send back the result }*/ /*** 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!!! ***//* END SP */