modeonz
Junior Member level 1
i am using spartan 3e ... i try to communicate with the pc by using serial communication ..... i use 50 mhz clk ..... i want to get 9600 baud rate to send a 8 bit register .... what is the value of the divisor should i take ..... i used 5208 for the divisor also i tried 1302 but i don't recive anything at the hyberterminal ?!!!!!! whatshould i do
i made this code
itried this code in the simulator and i get a true output by usind divisor= 5 to notice the output so i think the error will be in the baud rate
c is the clock
y is the tx
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
ENTITY cout IS
PORT(
c : IN std_logic;
rst : IN std_logic;
y : OUT std_logic
);
-- Declarations
END cout ;
-- hds interface_end
ARCHITECTURE muha OF cout IS
signal tm:std_logic_vector(15 downto 0):=(others=>'0');
constant div:integer:=5208;
signal clk:std_logic;
signal busy:std_logic:='0';
signal mess:std_logic_vector(9 downto 0) :=(others=>'0');
signal cout:std_logic_vector(15 downto 0 ):=(others=>'0');
BEGIN
clkgenrocess(rst,c)
begin
if rst='1' then
tm<=( others=>'0') ;
clk<='0';
elsif c='1' then
clk<='0';
if tm=div then
tm<=(others=>'0');
clk<='1';
else
tm<= tm + 1;
end if ;
end if ;
end process;
shifrocess(c)
begin
if busy='0' then
mess<="0111010111";
busy<='1';
elsif ( busy='1' ) then
if (clk='1'and c='1') then
y<=mess(9);
mess(9 downto 1)<=mess(8 downto 0 );
cout<=cout + 1;
end if;
end if;
if cout=20 then
busy<='0';
cout<=(others=>'0');
end if;
end process;
END muha;
i made this code
itried this code in the simulator and i get a true output by usind divisor= 5 to notice the output so i think the error will be in the baud rate
c is the clock
y is the tx
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
ENTITY cout IS
PORT(
c : IN std_logic;
rst : IN std_logic;
y : OUT std_logic
);
-- Declarations
END cout ;
-- hds interface_end
ARCHITECTURE muha OF cout IS
signal tm:std_logic_vector(15 downto 0):=(others=>'0');
constant div:integer:=5208;
signal clk:std_logic;
signal busy:std_logic:='0';
signal mess:std_logic_vector(9 downto 0) :=(others=>'0');
signal cout:std_logic_vector(15 downto 0 ):=(others=>'0');
BEGIN
clkgenrocess(rst,c)
begin
if rst='1' then
tm<=( others=>'0') ;
clk<='0';
elsif c='1' then
clk<='0';
if tm=div then
tm<=(others=>'0');
clk<='1';
else
tm<= tm + 1;
end if ;
end if ;
end process;
shifrocess(c)
begin
if busy='0' then
mess<="0111010111";
busy<='1';
elsif ( busy='1' ) then
if (clk='1'and c='1') then
y<=mess(9);
mess(9 downto 1)<=mess(8 downto 0 );
cout<=cout + 1;
end if;
end if;
if cout=20 then
busy<='0';
cout<=(others=>'0');
end if;
end process;
END muha;