MC9S12E64CFUE SCI0 9600 Receive problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S12E64CFUE SCI0 9600 Receive problem

1,852 Views
Taoufik
Contributor I
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 */

 
Hi,
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
Labels (1)
0 Kudos
4 Replies

509 Views
JimDon
Senior Contributor III
Was is the bus clock frequency you are using?

The value written to SCI0BD depends on the bus clock.

When you changed from 4800 to 9600, did you re-run processor expert?

Your listing shows 52 being written to the baud rate register. What value was written for 4800?
0 Kudos

509 Views
Taoufik
Contributor I
I've connect an other device working with the baudrate 9600 to my application, the data transfer works properly. But i receive wrong data when i send data from my PC (also an other PC) to my application. Sending data to my PC from my application also works properly.
4800: setReg16(SCI0BD, 104); 
9600: setReg16(SCI0BD, 52); 
Think you
0 Kudos

509 Views
JimDon
Senior Contributor III
What application on the pc are using to test with?
On the PC are you using a native com port or a USB com port?

If the board works with other devices, then something is up with the PC.
0 Kudos

509 Views
Lundin
Senior Contributor IV
The problem could also be an unsuitable choise of oscillator frequency for UART communication. Posting your SCI settings doesn't say anything to us unless we know the frequency. Do you get framing errors when you receive the data?
0 Kudos