SCI Send Problem with MC9S08AW16CFGE

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SCI Send Problem with MC9S08AW16CFGE

跳至解决方案
2,960 次查看
monXii
Contributor III

Hello all.

I am using the 08AW16 for a little Keyboard  with 24 Keys.

On each key pres and release i send an char..

 

my pcb is selfmade and done with our milling machine..

 

my problem is that the µC send all chars with 0x80 or'ed on it ?!

i send 0x01 and on my pc i saw 0x81 ..

i used the debugger and looked into the SCI1D and really saw the "0x01" !

the µC is clocked by a 8MHz Crystal oscilator..

the strange thing is that it runs on 1 hardware without any problems and on the next 2 i have this problem.. there are no short circuits or something else.. i have swapped the µC 2 times and then the problem wasn there, but comes again after 1-2 days ?!

i cant explain what is wrong cause first keyboard works very fine!

 

my next step would be to measure with my scope ..

 

.. but perhaps someone can help me?! :smileyhappy:

thanks so far!

 

here my SCI init and send routine:

 

void sci_Init(void){

  SCI1BDH = 0x00; // 9600 Baud
  SCI1BDL = 0x1A; // 9600 Baud
  SCI1C1  = 0x40; // 8 Bit, No Parity
  SCI1C2  = 0x08; // Tr On, Rec off, no interrupt
  //SCI1C2  = 0xC8; // Tr On, Rec off, with Tr interrupts
  SCI1C3  = 0x00;

}

void sci_Send_Byte(unsigned char data){
  while(!(((SCI1S1 & 0x40) == 0x40)
       && ((SCI1S1 & 0x80) == 0x80)));
  // .. wait till rdy to send ..

  SCI1D = data; // send data

}
标签 (1)
0 项奖励
回复
1 解答
693 次查看
monXii
Contributor III

hey peg, bigmac ..

thanks for your very fast help! :smileyhappy:

i read the manual again and setted all up, but didnt work..

.. after an hour measuring and experimenting, i noticed that one via in the xtal track wasnt correctly soldered (self made pcb).. =/ :smileytongue:

now it works very fine!

 

thanks,

Sascha.

在原帖中查看解决方案

0 项奖励
回复
9 回复数
693 次查看
peg
Senior Contributor IV

Hello monXii,

 

What you are almost certainly seeing here is a baudrate mismatch. One end of your link is running slightly faster than the other. When the MSB is being detected it is actually seeing the stop bit and as long as the bytes are sent with a small gap a valid enough stop bit can be detected by what is left of the actual stop bit and the idle line thereafter.

Are you running on the internal oscillator?

Is it trimmed properly?

What is your calculated baudrate based on the division of your expected busclock?

Do you sometimes get framing errors? Are you looking for them?

 

0 项奖励
回复
693 次查看
monXii
Contributor III

1. no, i use an external oscillator (8MHz)

2. i dont setted anything up like that.. i am using  the reset values for clock settings

3. my calculated baudrate is 4MHz / (16 * 26) = 9615 Baud

4. no, i dont see any framing errors

 

what can i do to solve the problem?

using another baudrate which has less tolerance?!

 

or how can i trimm the frequency?

 

thanks for your fast answer!

Message Edited by monXii on 2009-07-30 01:14 PM
0 项奖励
回复
693 次查看
bigmac
Specialist III

Hello, 


monXii wrote:

1. no, i use an external oscillator (8MHz)

2. i dont setted anything up like that.. i am using  the reset values for clock settings



These two statements seem to be contradictory.  Unless you specifically setup the ICG module to utilize an external oscillator, the reset values will make use of the internal oscillator.  Note also that there is a difference in the setup requirements, depending on whether you have an external crystal (two pins) or a packaged oscillator (one pin).

 

Regards,

Mac

0 项奖励
回复
693 次查看
monXii
Contributor III

bigmac,

mh ok.. i'll check it!

 

edit:

ICGC1 is now 0x60 ("High Frequency Range" and "external crystal oscillator")  ..

.. same effect.

 

now measuring ..

Message Edited by monXii on 2009-07-30 03:09 PM
0 项奖励
回复
693 次查看
peg
Senior Contributor IV

Hi,

 

You probably want an ICGC1 of 0x30 actually. And another read of that datasheet!

 

0 项奖励
回复
694 次查看
monXii
Contributor III

hey peg, bigmac ..

thanks for your very fast help! :smileyhappy:

i read the manual again and setted all up, but didnt work..

.. after an hour measuring and experimenting, i noticed that one via in the xtal track wasnt correctly soldered (self made pcb).. =/ :smileytongue:

now it works very fine!

 

thanks,

Sascha.

0 项奖励
回复
693 次查看
bigmac
Specialist III

Hello,

 

You have actually selected SCM mode, and this produces the least accurate clock rate.  To use an external crystal or resonator you will need to select either FBE or FEE mode.  The datasheet explains these modes.

 

Regards,

Mac

 

0 项奖励
回复
693 次查看
peg
Senior Contributor IV

Hi,

 

Well if your running on an external oscillator your only trim is the next baudrate divisor. As a quick test you could try lowering the baudrate drastically. Time to get the oscilloscope out I think. Compare the same character transmitted from either end.

 

Is the code on the PC end _looking_ for framing errors?

0 项奖励
回复
693 次查看
monXii
Contributor III

Yeah, i think so too.. Its time for the oscilloscope :smileyhappy:

I set the baudrate to 300 and the same ..

.. i tested some other values and its not only the MSB set ..

0x01 -> 0x81
0x02 -> 0x82
0x03 -> 0x83
0x04 -> 0x84
0x05 -> 0x85
0x06 -> 0x86
0x07 -> 0x87
0x08 -> 0x88
0x09 -> 0x89
0x0A -> 0x8A
0x0B -> 0x8B
0x0C -> 0x8C
0x0D -> 0x8D
0x0E -> 0x8E
0x0F -> 0x8F

0x10 -> 0x90
0x20 -> 0x80
0x30 -> 0x90
0x40 -> 0xA0
0x50 -> 0xB0
0x60 -> 0xA0
0x70 -> 0xB0
0x80 -> 0xC0
0x90 -> 0xD0
0xA0 -> 0xC0
0xB0 -> 0xD0
0xC0 -> 0xE0
0xD0 -> 0xF0
0xE0 -> 0xE0
0xF0 -> 0xF0

0x11 -> 0x91
0x22 -> 0x82
0x33 -> 0x93
0x44 -> 0xA4 (sometimes 84)
0x55 -> 0xB5
0x66 -> 0xA6
0x77 -> 0xB7
0x88 -> 0xC8
0x99 -> 0xD9
0xAA -> 0xCA
0xBB -> 0xDB
0xCC -> 0xEC
0xDD -> 0xFD
0xEE -> 0xEE
0xFF -> 0xFF

 

i think Bit7 goes to Bit6 and Bit6 goes to Bit5.. Bit4-0 stays.. and then 0x80 is OR'ed :smileyhappy:

sounds crazy, but check it .. :smileyvery-happy:

 

but i'll measure now and report in a few minutes..

 

and yes, the PC is looking for framing errors.

0 项奖励
回复