SCI transmission

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

SCI transmission

2,854 Views
ODUIEEECarTeam
Contributor I
I am working with the Adapt9s12XD512. When I try to transmit from the SCI pins, I can't even get any kind of signal on the oscilloscope.  I get a very clean looking 5V signal.  Do I need something else to make this work?
Here is my code (using codewarrior):
 
 SCI0BD = 0x0068;      //seems like I've tried every possible value for these...
SCI0CR1 = 0x00;       
SCI0ASR1 = 0x00;    
SCI0ACR1 = 0x00;    
SCI0ACR2 = 0x00;
SCI0CR2 = 0x0C;
 
  EnableInterrupts;
  for(;:smileywink: { //* wait forever / 
 
  while((SCI0SR1 & 0x80) == 0);
  g_temp = SCI0SR1; 
  SCI0DRL = 0xff;
  while((SCI0SR1 & 0x80) == 0);      //also tried !(this)
  g_temp = SCI0SR1; 
  SCI0DRL = 0x00;
}
 
 
 
(I also tried many different values for all the port S registers, which seemed to have no effect.)
 
What am I missing?
Labels (1)
0 Kudos
8 Replies

633 Views
allawtterb
Contributor IV
You are clearing your baud rate setting by trying to set SCI0ACR1 to 0, instead setting the baud rate to 0.  You should remove SCI0ASR1, SCI0ACR1 amd SCI0ACR2 assignments in your code (they are 0 by default anyway).  These registers share address space with SCI0BDH, SCI0BDL and SCI0CR1 respectively.  If you wish to access SCI0ASR1, SCI0ACR1 amd SCI0ACR2 you must set the AMAP bit in SCI0SR2. 
0 Kudos

633 Views
ODUIEEECarTeam
Contributor I
Ok. That worked, but I have another problem now.  When I run the program, I can see the data being outputed on the oscilloscope. However, when I connect it to this computer's serial port and try to look at the output, I get nothing.  I have tried many different baud rate settings, and still nothing. It seems like i have tried all the port S registers and still nothing....  Why can't Hyperterminal view my outputs??
0 Kudos

633 Views
allawtterb
Contributor IV
I would also suggest using another program other than Hyperterminal if you are sending anything other than ASCII data.  Try using Bray terminal, it is a free program.
 
 
Use a standard baud rate and if you are really uncertain if you are generating the correct baud rate you can always verify it with a scope. 
0 Kudos

633 Views
ODUIEEECarTeam
Contributor I
          I got to view my data output (in Realterm) after I got hyperterminal to display it once, and then didn't work the next time, and I'm pretty sure my baud rate was correct all along.  However, the data I got didn't quite make sense.  I tried capturing the output of the console program from which I can easily send the commands I want to the device (Brainstem Moto 1.0) that I am trying to communicate with, and also got data that did not quite make sense.  My code...
 
-" while((SCI0SR1 & 0x80) == 0);  //wait until the device is ready to transmit
  g_temp = SCI0SR1; 
  SCI0DRL = 0x04;
  while((SCI0SR1 & 0x80) == 0);  //wait until the device is ready to transmit
  g_temp = SCI0SR1; 
  SCI0DRL = 0x33;
  while((SCI0SR1 & 0x80) == 0);  //wait until the device is ready to transmit
  g_temp = SCI0SR1; 
  SCI0DRL = 0x01;
  while((SCI0SR1 & 0x80) == 0);  //wait until the device is ready to transmit
  g_temp = SCI0SR1; 
  SCI0DRL = 0x00; "
 
...gives me an output of "00 5F D6 FF 00"
 
          Able to find no simple relation beween these, confused, I captured the output from the console program that came with the Brainstem. 
I type: 4 51 1 0
The console: ">04:33,01,00"
On the terminal: "5F 99 FD FF 00"
again:
">04:40,0"
"DF 7F FF 00"
">04:3F,01,01,00,20"
"5F 5F FD FD FF BF 00"
 
          I cannot figure out any simple, consistent relation between the signals I send and what displays on the terminal.  I understand it may appear inverted since a 0 is high(5V) on the oscilloscope, but that cannot explain it.  The only possible explaination that I can find is from the Brainstem's reference:
-"Since the baud rate generator has a limited number of possible rates, the actual baud rate will differ slightly from the desired baud rate.  In some cases, this can effect communication with external serial devices.  The desired baud rates and actual baud rates are listed below.
...2 9600 9615 +0.16%..."
I also remember that when I used the equation in the 9s12x's documentation, it came out to not exactly 9600.
 
          Why am I getting this weird data that doesn't seem to match up?  Could it be attributed to a tiny difference(<10bps) in actual baud rates?
0 Kudos

633 Views
JimDon
Senior Contributor III
How are you connecting it?

What are you using for a level translator?

0 Kudos

633 Views
ODUIEEECarTeam
Contributor I
          Since my last post I actually got an output to a different terminal program(Realterm), but it was not what I expected. 
 
>>"How are you connecting it?"
          Directly from TXD0 to the RXD pin of my computer's serial port.
>>"What are you using for a level translator?"
          Nothing.  I did not know that I needed anything.  The waveform I generate looks just like the one generated from the console program that comes with the device (Brainstem Moto 1.0) I am trying to communicate with.  However, after reading your post I found this in the reference: 
- "Hosts have a variety of serial options and some require additional circuitry to communicate with the BrainStem Modules.  The interface cable houses the appropriate circuitry and terminates at both ends with the correct connectors for each host."
          Are they referring to a pull-up or pull-down device?  I was not sure what was meant by the following in the 9s12x's documentation:
-"PERS[7:0] — Pull Device Enable Port S
1 = Either a pull-up or pull-down device is enabled.
0 = Pull-up or pull-down device is disabled."
-"PPSS[7:0] — Pull Select Port S
1 = A pull-down device is connected to the associated Port S pin, if enabled by the associated bit in register PERS and if the port is used as input.
0 = A pull-up device is connected to the associated Port S pin, if enabled by the associated bit in register PERS and if the port is used as input or as wired-or output."
          Does this mean that the board has one internally that can be enabled by this setting, or is this a setting that needs to be set ONLY IF one is externally connected?
0 Kudos

633 Views
JimDon
Senior Contributor III
RS-232 works with -3 to -12 and +3 to +12, inverted. Meaning that -V is idle or marking state.
This is what the input to the pc expects. Hopefully you have not burned up the chip.
See if it still works disconnected.

One way is you can build or buy a MAX232 based module that does this translation.
They can be found from a number of sources.

These are usually called TTL to RS-232 converters. There are bunch on ebay. Just search on
"ttl rs232" and you will see examples. I have several of these on headers that I use.

There are also various trick circuits that might work, but you must invert the signal for sure.

Yes you should have a pull up, but you will need more than that.



Message Edited by JimDon on 2008-03-14 02:15 PM
0 Kudos

633 Views
allawtterb
Contributor IV


ODU IEEE Car Team wrote:
          Since my last post I actually got an output to a different terminal program(Realterm), but it was not what I expected. 
 
>>"How are you connecting it?"
          Directly from TXD0 to the RXD pin of my computer's serial port.
>>"What are you using for a level translator?"
          Nothing.  I did not know that I needed anything.  The waveform I generate looks just like the one generated from the console program that comes with the device (Brainstem Moto 1.0) I am trying to communicate with.  However, after reading your post I found this in the reference: 

This is part of the problem with trying to communicate with the computer.  Your microcontroller doesn't use RS-232 levels, it uses TLL/CMOS levels.  If you look at the following link, you will see a 2 waveforms from an O-scope, one blue and one yellow.  The blue is what your are sending and the yellow is what the computer is expecting.  The same goes for the computers transmission, it is sending the yellow and your microcontroller is expecting the blue.  These voltages the computer is sending could damage the pins on your microcontroller so if you have hooked up the transmit of the computer to your S12X I would suggest you remove it immediately.  
 
 
It seems like the Brainstem module you are trying to communicate with doesn't use RS-232 levels either and should communicate fine with your S12X as is.  The problem will be you can't debug to your computer this way.  To communicate with the computer you would need a level translator like the standard MAX232.
 
 
 
0 Kudos