Baud generator

Thread Starter

WrEtCh

Joined Jan 13, 2010
2
Hello,

I have written a code for a 115200 bps rate serial port adapt to 50 MHz clock (50MHz/115200*16) = 27.1267. That means that every 27 cycle a bit is sent, but as long as the number is not precise there might be some fluctuations after some cycles. Can you give me a tip on how to lets say implement a counter that counts serial port cycles and lets say after 8 of these cycles make a rate of 26 not 27 and then comes back to 27 again.

this is my code

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is port(C, CLR : in std_logic;
Q : out std_logic_vector(4 downto 0);
Z: out bit);
end counter;
architecture archi of counter is
signal tmp: std_logic_vector(4 downto 0);
begin
process (C, CLR)
begin
if (CLR='1') then
tmp <= (others =>'0');
Z <= '0';
elsif (C'event and C='1') then
tmp <= tmp + 1;
Z <= '0';
if (tmp = "11011") then
tmp <= (others =>'0');
Z <= '1';
end if;
end if;
end process;
Q <= tmp;
end archi;

Thnx
 

retched

Joined Dec 5, 2009
5,207
[ed]
Woah, are you trying to steal my name? kidding.
[ed]

Im sorry, are you trying to use the serial in as a clock?
It sounds to me like you want to :

send 115200 bits every second
count each bit
when the count hits 27,
do something
reset counter and start again

is this correct?

Or are you saying you want to use a program to read the port at 115200bps?
If thats the case, lemme know. 115200 doesn't mean that a bit is sent every 27 cycles af 50Mhz. It means it CAN be sent that fast.
THE PROBLEM:
If I send a 1 to the port and your proggy picks it up, you will have a 1.
If my side burps for 108 cycles before sending the 2nd bit, say a '0' you will have READ '11110' instead of the '10' I wanted to send.
 
Last edited:

Thread Starter

WrEtCh

Joined Jan 13, 2010
2
Okey.

I got a little confused, so lets start from the begining :)


I have a serial port on a altera device and one of the bit rates that are suitable for RS232 is 115200 bps right? Therefore I want to create a baud generator for the UART to send information to the RS232 in 115200 bps speed. What is more as a initial point Im going to use default frequency of 50MHz. The idea I thought of is creating a counter that is counting up to (50Mhz/115200) and makes a tick for the UART to send a bit towards the RS232.

Another problem met is that the number when we divide the numbers is not precise, therefore after some time there will be some delays. I was wondering how to cope with this problem?

Im just starting to work with VHDL so I wonder if Im thinking correctly. Thanks for the help :)
 
Top