zrkd51
Newbie level 4
Hello ,
I've been reading a lot of examples of UART codes in VHDL for port RS232, so I wrote my own version, or at least tried, the problem is , I don't get to see a single character when I'm trying to test it with Hyperterminal, I'm using a Nexys2. Am I doing something wrong?
Below, the code, I would appreciate any help, thanks:
Code:
I've been reading a lot of examples of UART codes in VHDL for port RS232, so I wrote my own version, or at least tried, the problem is , I don't get to see a single character when I'm trying to test it with Hyperterminal, I'm using a Nexys2. Am I doing something wrong?
Below, the code, I would appreciate any help, thanks:
Code:
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity main is
Port ( txd : out STD_LOGIC := '1';
data: inout STD_LOGIC_VECTOR (9 downto 0);
clk: in STD_LOGIC;
act: inout STD_LOGIC;
do: inout STD_LOGIC;
swt: in STD_LOGIC_VECTOR (7 downto 0);
btn: in STD_LOGIC;
led: out STD_LOGIC_VECTOR (7 downto 0));
end main;
architecture Behavioral of main is
begin
led <= swt;
data <= '1' & swt & '0'; --Data Vector
activar: process (clk,btn)
variable cont: integer range 0 to 5000000;
begin
if (rising_edge (clk)) then
if btn = '1' and cont < 5000000 and do = '0' then
cont := cont + 1;
act <= '0';
elsif btn = '1' and cont >= 5000000 and do = '0' then
act <= '0';
elsif btn = '0' and cont < 5000000 and do = '0' then
cont := 0;
act <= '0';
elsif btn = '0' and cont >= 5000000 and do = '0' then
act <= '1';
cont := 0;
end if;
end if;
end process; --Fin Activar
envia: process (act,clk)
variable cont: integer range 0 to 16:=0;
variable cont2: integer range 0 to 8192 := 0;
begin
if (rising_edge (clk)) then
if (cont2 < 5208) then--Counter for 9600 bauds
cont2 := cont2 + 1;
else
if (act = '1') then
if (cont = 0) then
do <= '1';
txd <= data (cont);
cont := cont + 1;
elsif (cont < 9) then
txd <= data(cont);
cont := cont + 1;
else
txd <= data(cont);
cont := 0;
do <= '0';
end if;
end if;
cont2 :=0;
end if;
end if;
end process;
end Behavioral;