barzel
Newbie level 2
hi all
i wrote a vhdl code for uart receiver, but i cant get the 9600 bps with my Altera kit.
i use Altera cycloneII FPGA development kit [EP2C20F484C7N].
there is 3 kind of clocks 24Mhz, 27MHz and 50MHz.
my uart code use counter that count a clocks and every 16 ticks its one bit.
thats mean i need 16*9600 = 153600[Hz] frequency. how can i do that?
clock/X=153600 => X=175.78125 [for 27MHz] i divide for 176
i wrote a simple code:
what is wrong or how can i do it better?
please help me.
i wrote a vhdl code for uart receiver, but i cant get the 9600 bps with my Altera kit.
i use Altera cycloneII FPGA development kit [EP2C20F484C7N].
there is 3 kind of clocks 24Mhz, 27MHz and 50MHz.
my uart code use counter that count a clocks and every 16 ticks its one bit.
thats mean i need 16*9600 = 153600[Hz] frequency. how can i do that?
clock/X=153600 => X=175.78125 [for 27MHz] i divide for 176
i wrote a simple code:
what is wrong or how can i do it better?
Code:
library ieee;
use ieee.std_logic_1164.all;
entity uart_frq is
generic ( Thigh : integer := 176);
port( frqin : in std_logic;
frqout : out std_logic;
reset :in std_logic);
end uart_frq;
architecture behave of uart_frq is
signal cnt: integer range 0 to Thigh;
begin
process(frqin)
begin
if reset='1' then cnt<=0; frqout<='0';
elsif frqin'event and frqin='1' then
cnt<=cnt+1;
if cnt<88 then
frqout<='1';
elsif cnt>=88 then
frqout<='0';
elsif cnt=176 then cnt<=0;
end if;
end if;
end process;
end behave;
please help me.