Maker Pro
Maker Pro

Problem with 6402 UART.

Hello, I am trying to build an RS232 Keypad. I'm using a 74C922 16-Keys
Encoder to convert the keypad input to 4bits data. I then pass it to
the 6402 UART to convert the data from parallel to serial.
I'm using the circuit found here
http://www.beyondlogic.org/serial/serial3.htm to the exception that I
run the circuit with a 20Mhz crystal (so I use Q5 on the 74HC4060).
It's not perfect as I would need 19.6608Mhz for 19200bps but iirc the
UART has a 3% margin. I've also noticed that Y pins on the 74C922 are
inverted from what they should be. The UART runs with no parity, 8bits
word, 1 stop bit and at 19200bps. Now I do get some data sent through
but the words are very weird. They appear something like 0 # 0 #, where
# is some odd number and not 0 to 16 as it should be. I know it is not
the MAX232 as it's output is connected to a VFD and that works fine.
I've tried replacing the UART to no avail, same for the 74C4060. I
haven't tried to change the 74C922 as it's quiet expensive and I only
have one but anyway I get similar data if I just tie pins low/high
manually. I've tried using a different, slower crystal at 14400bps, no
go. The best I get is scrambled data or simply invalid data (sometimes
with only pin one is high it output 3 instead of 1!!!). I really don't
understand why, any help would be appreciated!

Matth
 
Hello, I am trying to build an RS232 Keypad. I'm using a 74C922 16-Keys
Encoder to convert the keypad input to 4bits data. I then pass it to
the 6402 UART to convert the data from parallel to serial.
I'm using the circuit found here
http://www.beyondlogic.org/serial/serial3.htm to the exception that I
run the circuit with a 20Mhz crystal (so I use Q5 on the 74HC4060).
It's not perfect as I would need 19.6608Mhz for 19200bps but iirc the
UART has a 3% margin. I've also noticed that Y pins on the 74C922 are
inverted from what they should be. The UART runs with no parity, 8bits
word, 1 stop bit and at 19200bps. Now I do get some data sent through
but the words are very weird. They appear something like 0 # 0 #, where
# is some odd number and not 0 to 16 as it should be. I know it is not
the MAX232 as it's output is connected to a VFD and that works fine.
I've tried replacing the UART to no avail, same for the 74C4060. I
haven't tried to change the 74C922 as it's quiet expensive and I only
have one but anyway I get similar data if I just tie pins low/high
manually. I've tried using a different, slower crystal at 14400bps, no
go. The best I get is scrambled data or simply invalid data (sometimes
with only pin one is high it output 3 instead of 1!!!). I really don't
understand why, any help would be appreciated!

Matth

If you're simply trying to double the baud rate from 9.6K to 19.2K,
just double the crystal frequency. IIRC it's a standard part. OR, use a
different baud rate generator that has the Q3 output available. 20MHz
is getting near the max rate for the HC4060 AND you may be running into
3rd overtone issues as well. The lower frequency crystals will cause
you much less grief. For higher frequencies its much easier to use
oscillator blocks and let somebody else deal with the problems.

ALSO, are you initializing the LCD module properly? Its very important
that it be done in precisely the sequence and timing specified. If you
follow the rules, it will work correctly. You will also need to find
and observe the cursor positioning data so it writes to the correct
place in the display. Look up data on the HD44780.

Good luck
GG
 
A

Anthony Fremont

Hello, I am trying to build an RS232 Keypad. I'm using a 74C922 16-Keys
Encoder to convert the keypad input to 4bits data. I then pass it to
the 6402 UART to convert the data from parallel to serial.
I'm using the circuit found here
http://www.beyondlogic.org/serial/serial3.htm to the exception that I
run the circuit with a 20Mhz crystal (so I use Q5 on the 74HC4060).
It's not perfect as I would need 19.6608Mhz for 19200bps but iirc the

This may sound stupid, but how come you are using a crystal that is 8
times faster, but only stepping up the divisor by a factor of 2. 20MHz
/ 32 = 625000 (as determined by using Q5 on 4060). 625000/16 (UART
divisor) = 39062 or IOW about 38.4Kbaud. Shouldn't you be using Q7 on
the 4060?
UART has a 3% margin. I've also noticed that Y pins on the 74C922 are
inverted from what they should be. The UART runs with no parity, 8bits
word, 1 stop bit and at 19200bps. Now I do get some data sent through
but the words are very weird. They appear something like 0 # 0 #, where
# is some odd number and not 0 to 16 as it should be. I know it is not

Sounds like a possible baudrate mismatch again. Data sent from a PC at
19.2K and received by a UART expecting 38.4K will be seen as two bytes
of data along with a possible framing error depending upon the data
being sent.
 
A

Anthony Fremont

Anthony Fremont said:
This may sound stupid, but how come you are using a crystal that is 8
times faster, but only stepping up the divisor by a factor of 2. 20MHz
/ 32 = 625000 (as determined by using Q5 on 4060). 625000/16 (UART
divisor) = 39062 or IOW about 38.4Kbaud. Shouldn't you be using Q7 on
the 4060?

Oops, I should have said Q6 instead of Q7. AIUI, the UART needs a clock
of 307.2kHz (16 * 19,200), meaning that your 4060 needs to divide the
20MHz crystal by 65.1. The closest you can come is a divisor of 64.
You seem to be using a divisor of 32 resulting in a baud rate of roughly
38.4K instead of the desired 19.2K.

From the UARTs perspective, all of your bits look like two bits. So
sending a single bit set will result in the UART interpreting that bit
twice.
 
First of all let's forget LCD initialization, I don't have anything
pluged in on the UART's output.
As for clock rate. I'm very confused. As far as I can see on that page
(beyondlogic) Q4 has a divider of 32 and Q5 of 64. Admittedly the
datasheet reports a devider of 16 for Q4. Furthermore, none of the
references/datasheet seem to report the same pinout. Nonetheless I've
tried Q4 to Q7 with similar results. Now I'm left wondering, shouldn't
I reduce the load capacitors if I bring the frequency up? I'm still
using 22pF capacitors.
 
A

Anthony Fremont

First of all let's forget LCD initialization, I don't have anything
pluged in on the UART's output.
As for clock rate. I'm very confused. As far as I can see on that page
(beyondlogic) Q4 has a divider of 32 and Q5 of 64. Admittedly the

I'm not sure where you see that, they show using a XTAL of 2.4576MHz and
obtaining an output frequency of 153.6kHz. That is clearly a divisor of
16 by using Q4. The UART happens to divide by 16 as well, but that
aparently doesn't change.
datasheet reports a devider of 16 for Q4. Furthermore, none of the
references/datasheet seem to report the same pinout. Nonetheless I've
tried Q4 to Q7 with similar results. Now I'm left wondering, shouldn't

Q6 is the correct output assuming a 20MHz XTAL and a 19,200 desired baud
rate.
I reduce the load capacitors if I bring the frequency up? I'm still
using 22pF capacitors.

AFAIK that should still work, but as someone else said things start
getting fairly touchy at those frequencies. I would go with a smaller
XTAL if possible.
 
Well you guys were right, 20Mhz was getting touchy. I had a ~14Mhz XTAL
laying around so I decided to try at 14400bps (since I can generate
that baud rate at 14Mhz)... It worked :D
So I'll drop by the electronic shop tomorrow and get a 5Mhz crystal.
That way I should still be able to generate a proper clock rate for
19200bps (I need this baud rate since that's what the VFD uses and it's
on the same line) but with a much more acceptable XTAL frequency.

Thanks a million guys :)

Matth is a happy camper!
 
Top