SCI problem

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

SCI problem

713 Views
fuma
Contributor I

Hi,

I have a problem with the SCI comunication with two MC9S08GT32, my code for 9600 baud N 8 1.  is:

Init_SCI1:
       mov   #$00,SCI1BDH      
       mov   #$80,SCI1BDL      
       mov   #$64,SCI1C1          
       mov   #$0C,SCI1C2       
       mov   #$00,SCI1S2       
       mov   #$20,SCI1C3 

 

I work with an internal oscillator and the internal bus clock is 19.995429MHz, the CPU clk is 39.99MHz for the two micro.
I look with the scope the output signal and apparently are correct,the micro recive read the data but some times are correct, other times are wrong.I think that my problem is the work frequency, I generate a signal with a nop instruction, in one micro ton=340ns toff=230ns, in the other ton=450ns and toff=300ns, the time are identical with/without the
emulator.
For this test the pin of two micro are connected with an 100R resistor and the signal are very good.
Can you help me?

thanks   Fabio

Labels (1)
0 Kudos
2 Replies

357 Views
peg
Senior Contributor IV

Hello Fabio,

 

I run 9600 baud on a GT16A with the same clock, here is my SCI Init:

 

*************** SET UP SERIAL COMMS *****************************************

        CLR    SCI1BDH
        MOV    #(mSBR7|mSBR1),SCI1BDL    ;set baudrate to 9613 baud
        MOV    #mILT,SCI1C1        ;set idle line type select to after stop bit
        MOV    #(mRIE|mTE|mRE),SCI1C2    ;enable reciever interrupts, Tx and Rx enable

Also you need to have the internal clock trimmed to ensure correct baudrate.

Don't have time, didn't go through what you have, just sent you what works here.

 

0 Kudos

357 Views
i_kauf
Contributor III

Hello Fabio!

 

BR Value should be 130 in decimal for ~20Mhz. Then you will have 9613 baud in real. That should be close enought.

With factor hex 82 you will have 9763 baud and this seems not close enought.

 

Note that  if you write in your code mov   #$0C,SCI1C2 than both receiver and transmitter are off. But I am sure that this depends on your application.

 

use mov   #$82,SCI1BDL and it should work.

 

regards,

 

Ingo

0 Kudos