Altera_Forum
Honored Contributor
14 years agoRS232 command interpreter vhdl
Hello everyone, I came here in order to find any suggestion for the following issue.
I have a fpga custom board wich needs to make a task depending on the command received by a mcu or pc. For instance, the command <SW> followed by n bytes of data will change the frequency of a DDS system, and so on with other 4 bytes commands (4 ASCII chars). I already have my UART component workin and tested with the windows hyperterminal wich echos back every key pressed. I tried with a 8bit shift left register and a counter in order to "concatenate" the command and later compare it in order to perform the correspondig action, but I just can't make it work. Does anyone already did something like that before? the pseudo code is the following
...
architecture arch of myEntity is
signal RxReady : std_logic;
signal enableTx : std_logic;
signal cmd : std_logic_vector(31 downto 0) := (others => '0');
signal cmd_tmp : std_logic_vector(31 downto 0) := (others => '0');
signal tmp_data : std_logic_vector(7 downto 0) := (others => '0');
signal cont : integer range 0 to 4 := 0;
begin
u1 : UART port map (sysclk, sysrst, enableTx, TxD, TxData, RxD, tmp_data, RxReady);
process(sysrst, tmp_data, RxReady)
begin
if sysrst = '1' then
enableTx <= '0';
cmd <= (others => '0');
cmd_tmp <= (others => '0');
else
if RxReady = '1' then
if cont < 4 then
cont := cont + 1;
cmd_tmp <= cmd_tmp(23 downto 0) & tmd_data;
cmd <= cmd_tmp;
else
cont := 0;
end if;
else
end if;
end if;
end process;
process(cmd)
begin
-- just a Test, but not working, it only has the last char coming from the PC, i.e, a sequence 1234, should be 1234, but it is just 4444
if cmd = one&two&three&four then
outLEDS <= (others => '1');
else
outLEDS <= (others => '0');
end if;
end process;
end architecture;
...
If anyone have a suggestion it will be really appreciated. Thanks in advance.