Taoufik El Boubkari

MC9S12E64CFUE SCI0 9600 Receive problem

Discussion created by Taoufik El Boubkari on Aug 10, 2007
Latest reply on Aug 14, 2007 by Daniel Lundin
#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 */

I'm trying to make a simple code for data transmit (send/receive) with the serial port of the MC9S12E64CFUE.
Data which i send from the processor to the PC arrives normallly, but receiving data from the PC doesn't work. The charachters are detected when they arrives, but the contents are wrong.
I send also my source code?
Can anybody test this code? Otherwise if you have the wright configuration, can you send it to me??
With the baudrate 4800 it works properly!!

Message Edited by Taoufik on 2007-08-10 09:32 AM