SCI Receive Problem w/ RS08KB2

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

SCI Receive Problem w/ RS08KB2

Jump to solution
864 Views
Paul_STL
Contributor I

Hello everyone,

 

I'm a long time reader but a first time poster here. I'm using an RS08KB2 microcontroller with CodeWarrior v10.1 and I'm having a lot of trouble receiving data through the SCI module. Everything I receive is gibberish.

 

To begin, I've re-mapped the SCI pins in SOPT1 since I'm using an 8 pin device. I also trimmed the ICS (I'm using a P&E Micro USB Multilink). At this point, I'm trying to get any meaningful data from the SCI module so I'm just polling it. Here's how I set the module up (I'm running the chip at the standard 4MHz bus speed):

 

SCIBD = 0x001A;     // 9600 baudSCIC1 = 0x00;SCIC2 = 0x0C;       // Enable RxD and TxD

 Here's what I'm doing to receive the data ('test' is a 64 byte long array):

 

for(;;){    while(!SCIS1_RDRF);        if(SCIS1_OR){         test[i] = SCID;    }    test[i] = SCID;    i++    if(i>64){         i=0;    }}

Pretty straightforward, right? I've sent data through the transmitter and I'm measuring ~0.1ms per bit with my oscilloscope; I believe that corresponds to the correct 9600 baud rate. I've also connected the device I'm trying to read to my computer with a USB-serial adapter, and I can read the data with TeraTerm or HyperTerminal with no problems (8 data bits, no parity, 1 stop bit, no flow control).

 

The SCI module in the RS08 is receiving something, but it's complete nonsense. The data I received through TeraTerm consists of standard ASCII characters, the data I'm receiving through the SCI module is all over the place: nonsensical control characters, large numbers like 0xEB, 0x82, etc.

 

I figured maybe the BDM was impacting the timing, so at one point, I even had the code send a character on the TxD pin if it received a valid character. I ran the code, removed the BDM, and watched for changes on the oscilloscope: alas, nothing.

 

I'm not sure what's wrong, but I feel like I've tried everything! Thanks so much for your help!

 

 

 

-Paul

Labels (1)
0 Kudos
1 Solution
583 Views
bigmac
Specialist III

Hello, and welcome to the forum.


Paul@STL wrote:

I traced the signal directly to the microcontroller pin, and it appears to arrive there in good shape. It's a +10-12V signal, so I clamped it to +5V with a resistor and Schottky diode.

 


This would seem to suggest that you are directly connecting the TxD and RxD pins from the host computer, directly to the MCU pins.  Firstly, you risk damaging the MCU with over-voltage, and with possible static discharge.  Both MCU pins require additional interface circuitry to provide the necessary protection, and the correct operation of the SCI.  Traditionally this is provided by a MAX232 device, or similar.

 

A second issue is that the interface devices normally provide polarity inversion for both the transmitter and the receiver.  With direct connection, you do not provide this external inversion, as required by the POR default SCI setup.  For special circumstances, it is possible to internally invert the polarity of the TxD signal, the RxD signal, or both.  The control bits SCIC3_TXINV and SCIS2_RXINV are available for this purpose.

 

For the received data, the incorrect polarity would mean that the start bit of each character would not be properly detected, hence the garbage.

 

Regards,

Mac


 

View solution in original post

0 Kudos
4 Replies
583 Views
Paul_STL
Contributor I

Here's some more information on the matter:

 

I traced the signal directly to the microcontroller pin, and it appears to arrive there in good shape. It's a +10-12V signal, so I clamped it to +5V with a resistor and Schottky diode.

 

There are no error flags set in the SCIS1 status register, but I suppose that doesn't necessarily mean there aren't any errors.

 

The target doesn't have its own power supply and I was previously powering it with +5V from my bench power supply. I once had a noise issue when powering a microcontroller directly from my bench power supply, so this MCU is now powered by a 9V battery and a linear regulator. 

0 Kudos
584 Views
bigmac
Specialist III

Hello, and welcome to the forum.


Paul@STL wrote:

I traced the signal directly to the microcontroller pin, and it appears to arrive there in good shape. It's a +10-12V signal, so I clamped it to +5V with a resistor and Schottky diode.

 


This would seem to suggest that you are directly connecting the TxD and RxD pins from the host computer, directly to the MCU pins.  Firstly, you risk damaging the MCU with over-voltage, and with possible static discharge.  Both MCU pins require additional interface circuitry to provide the necessary protection, and the correct operation of the SCI.  Traditionally this is provided by a MAX232 device, or similar.

 

A second issue is that the interface devices normally provide polarity inversion for both the transmitter and the receiver.  With direct connection, you do not provide this external inversion, as required by the POR default SCI setup.  For special circumstances, it is possible to internally invert the polarity of the TxD signal, the RxD signal, or both.  The control bits SCIC3_TXINV and SCIS2_RXINV are available for this purpose.

 

For the received data, the incorrect polarity would mean that the start bit of each character would not be properly detected, hence the garbage.

 

Regards,

Mac


 

0 Kudos
583 Views
Paul_STL
Contributor I

Thank you Mac,

 

I did indeed connect the RxD pin to the host (not a PC) without an interface IC, but the resistor/diode clamped the signal to an acceptable voltage. Nevertheless, the signal polarity was the problem. This is a receive-only application, so I opted for a transistor as a level-shifter/inverter as opposed to a full blown MAX232. I looked for the RXINV bit in the control registers, but it doesn't seem like it exists in RS08 devices.

 

Thanks so much for your insight. The signal polarity even crossed my mind once, but I didn't investigate any further...

 

 

Paul

 

 

0 Kudos
583 Views
Paul_STL
Contributor I

Slight correction: I see the RXINV bit in the SCIS2 register now... my mistake. Thanks again!

0 Kudos