EmbeddedRelated.com
Forums
Memfault Beyond the Launch

SCC2692 UART

Started by Folkert van Heusden December 18, 2006
Hi,

As some of you may know from a previous post, I'm working on communicating 
with a SCC2692 UART connected to a 8051 processor. Now someone told me that 
it is memory mapped at 0x8000 so that brings me a small step further.
I tried configuring it as the documents describe but I get not a single bit 
over the line it seems (testing it with a connection to a pc with 
hyperterm).
What I do:
first I define a couple of xdata thingies. If I understood well, xdata 
points to some special memory of the 8051 to which devices are connected 
(please correct me if I'm wrong):
xdata char PCUART_MR1_2A _at_ 0x8000;
xdata char PCUART_CSRA   _at_ 0x8001;
xdata char PCUART_CRA    _at_ 0x8002;
xdata char PCUART_RXTX   _at_ 0x8003;
xdata char PCUART_IMR    _at_ 0x8005;
then I program the UART:
 PCUART_CRA = 0x15; /* 00010101 -> enable rx/tx & select mr1a */
 PCUART_MR1_2A = 0x43; /* 01000011 -> 8 bits even parity */
 PCUART_MR1_2A = 0x07; /* 00000111 -> 1 stopbit */
 PCUART_IMR = 0x02; /* 00000010 -> RxRDY/FFULLA INT */
 PCUART_CSRA = 0xbb; /* 10111011 -> 9k6 recv, 9k6 send */
I'm trying to get it in 9600 baud, 8 bits, even parity and one stopbit here.
and then as a test i have this loop:
for(loop=0; loop<100; loop++)
{
 PCUART_RXTX = '*';
 Delay(50);
}
Now the pc-end doesn't receive a single byte.
Can someone see what I'm doing wrong here?
Any help is appreciated!


Folkert van Heusden wrote:

> Hi, > > As some of you may know from a previous post, I'm working on communicating > with a SCC2692 UART connected to a 8051 processor. Now someone told me that > it is memory mapped at 0x8000 so that brings me a small step further. > I tried configuring it as the documents describe but I get not a single bit > over the line it seems (testing it with a connection to a pc with > hyperterm). > What I do: > first I define a couple of xdata thingies. If I understood well, xdata > points to some special memory of the 8051 to which devices are connected > (please correct me if I'm wrong): > xdata char PCUART_MR1_2A _at_ 0x8000; > xdata char PCUART_CSRA _at_ 0x8001; > xdata char PCUART_CRA _at_ 0x8002; > xdata char PCUART_RXTX _at_ 0x8003; > xdata char PCUART_IMR _at_ 0x8005; > then I program the UART: > PCUART_CRA = 0x15; /* 00010101 -> enable rx/tx & select mr1a */ > PCUART_MR1_2A = 0x43; /* 01000011 -> 8 bits even parity */ > PCUART_MR1_2A = 0x07; /* 00000111 -> 1 stopbit */ > PCUART_IMR = 0x02; /* 00000010 -> RxRDY/FFULLA INT */ > PCUART_CSRA = 0xbb; /* 10111011 -> 9k6 recv, 9k6 send */ > I'm trying to get it in 9600 baud, 8 bits, even parity and one stopbit here. > and then as a test i have this loop: > for(loop=0; loop<100; loop++) > { > PCUART_RXTX = '*'; > Delay(50); > } > Now the pc-end doesn't receive a single byte. > Can someone see what I'm doing wrong here? > Any help is appreciated! > >
Lets look at the hardware again. Do you know how to use a multimeter ?? Measure the voltage at pins 2 and 3 to pin 5 of the serial port connector on the 8051 board. If the board is wired normally, pin 3 should be -9V to -12Volts. Now measure the voltage on the cable from the PC, same pins. Pin 2 should be -9 to -12Volts. If pin 2 or pin 3 on each end is -Volts, you will never see anything. Do you have a scope available ?? If the pins seem to be wired correctly, place your scope probe on the -Volts pin of the 8051 and ground on pin 5. Run your program and see if the pin drives between -volts an + volts. Good luck donald PS: Is this a custom board design or did you buy it off the shelf ?
Hi Donald,

Thanks again for replying!

>> As some of you may know from a previous post, I'm working on >> communicating with a SCC2692 UART connected to a 8051 processor. Now >> someone told me that it is memory mapped at 0x8000 so that brings me a >> small step further. >> I tried configuring it as the documents describe but I get not a single >> bit over the line it seems (testing it with a connection to a pc with >> hyperterm). >> What I do: >> first I define a couple of xdata thingies. If I understood well, xdata >> points to some special memory of the 8051 to which devices are connected >> (please correct me if I'm wrong): >> xdata char PCUART_MR1_2A _at_ 0x8000; >> xdata char PCUART_CSRA _at_ 0x8001; >> xdata char PCUART_CRA _at_ 0x8002; >> xdata char PCUART_RXTX _at_ 0x8003; >> xdata char PCUART_IMR _at_ 0x8005; >> then I program the UART: >> PCUART_CRA = 0x15; /* 00010101 -> enable rx/tx & select mr1a */ >> PCUART_MR1_2A = 0x43; /* 01000011 -> 8 bits even parity */ >> PCUART_MR1_2A = 0x07; /* 00000111 -> 1 stopbit */ >> PCUART_IMR = 0x02; /* 00000010 -> RxRDY/FFULLA INT */ >> PCUART_CSRA = 0xbb; /* 10111011 -> 9k6 recv, 9k6 send */ >> I'm trying to get it in 9600 baud, 8 bits, even parity and one stopbit >> here. >> and then as a test i have this loop: >> for(loop=0; loop<100; loop++) >> { >> PCUART_RXTX = '*'; >> Delay(50); >> } >> Now the pc-end doesn't receive a single byte. >> Can someone see what I'm doing wrong here? >> Any help is appreciated! >> > Lets look at the hardware again. > Do you know how to use a multimeter ?? > Measure the voltage at pins 2 and 3 to pin 5 of the serial port connector > on the 8051 board. > If the board is wired normally, pin 3 should be -9V to -12Volts. > Now measure the voltage on the cable from the PC, same pins. > Pin 2 should be -9 to -12Volts. > If pin 2 or pin 3 on each end is -Volts, you will never see anything.
Ok, checked that. 3 on the board is -9V, 2 on PC is -9V.
> Do you have a scope available ??
Unfortunately not...
> If the pins seem to be wired correctly, place your scope probe on > the -Volts pin of the 8051 and ground on pin 5. > Run your program and see if the pin drives between -volts an + volts.
Nothing happens. So I think I can conclude that 0x8000 is not the correct offset for the uart.
> PS: Is this a custom board design or did you buy it off the shelf ?
Some custom board design without documentation or even schematics.
On Mon, 18 Dec 2006 14:20:52 +0100, "Folkert van Heusden"
<folkert@vanheusden.com> wrote in comp.arch.embedded:

> Hi, > > As some of you may know from a previous post, I'm working on communicating > with a SCC2692 UART connected to a 8051 processor. Now someone told me that > it is memory mapped at 0x8000 so that brings me a small step further. > I tried configuring it as the documents describe but I get not a single bit > over the line it seems (testing it with a connection to a pc with > hyperterm).
Do you have the knowledge and access to use an oscilloscope or logic analyzer? These are what you need. Do you have a schematic for your board? Can you read it? The first thing you need to do is find out of the address "someone" gave you is correct. You could determine that from a schematic, if the chip select is done with logic gates, but maybe not if it is done with a programmable logic device. If the chip select for the UART is done with programmable logic, you will need the scope or analyzer to verify that it actually pulses when you write to these addressed. A way to do somewhat of a check is to see if you can read back the UART registers to see if they contain the values that you wrote.
> What I do: > first I define a couple of xdata thingies. If I understood well, xdata > points to some special memory of the 8051 to which devices are connected > (please correct me if I'm wrong): > xdata char PCUART_MR1_2A _at_ 0x8000; > xdata char PCUART_CSRA _at_ 0x8001; > xdata char PCUART_CRA _at_ 0x8002; > xdata char PCUART_RXTX _at_ 0x8003; > xdata char PCUART_IMR _at_ 0x8005; > then I program the UART: > PCUART_CRA = 0x15; /* 00010101 -> enable rx/tx & select mr1a */ > PCUART_MR1_2A = 0x43; /* 01000011 -> 8 bits even parity */ > PCUART_MR1_2A = 0x07; /* 00000111 -> 1 stopbit */
The two lines above seem wrong. First you write one value to a register than you write a different value to the same register, which seems like it would overwrite the first value.
> PCUART_IMR = 0x02; /* 00000010 -> RxRDY/FFULLA INT */
You probably don't want to enable interrupts at this point.
> PCUART_CSRA = 0xbb; /* 10111011 -> 9k6 recv, 9k6 send */
How do you know this is the correct value to set the baud rate you want? The value for a baud rate divisor depends on the frequency of the clock that the UART is receiving. Do you know the frequency?
> I'm trying to get it in 9600 baud, 8 bits, even parity and one stopbit here. > and then as a test i have this loop: > for(loop=0; loop<100; loop++) > { > PCUART_RXTX = '*'; > Delay(50);
You are trying to send a 10-bit character at 9600 baud, which takes more than one millisecond. Are you sure that your Delay() routine lasts more than one millisecond when called with a value of 50? Without knowing what is in your routine, I can't tell. But if you are writing another character while the current one is still transmitting, you could be generating gibberish on the line that the PC can't receive.
> } > Now the pc-end doesn't receive a single byte. > Can someone see what I'm doing wrong here? > Any help is appreciated! >
Here again is where you really need a scope or analyzer. You need to look at the transmit pin of the UART and see if it is pulsing. And if it is, to see what the period of the pulses is, to see if you are setting the correct baud rate. It is easiest to analyze serial transmission problems if you set the parameters to 7-bit data, no parity, and 1 stop bit. The result should be a continuous square wave on the output. For 9600 baud, the high time and low time of the square wave should be about 104 microseconds. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://c-faq.com/ comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
Folkert van Heusden wrote:
> Hi Donald, > > Thanks again for replying! > > > Some custom board design without documentation or even schematics.
Without some documenation you are lost. ( I know, obvious ) Get the data sheets of _all_ the parts on the board and trace it out. If I had a board like this in front of me, thats what I would do. Good Luck donald

Memfault Beyond the Launch