timer with or without reset?

Joined
Oct 15, 2009
Messages
7
Reaction score
0
This code is designed to output a square wave with freq dot(morse code) when an s is pressed on a keyboard. it is nearly working. the problem is that i have a timer that counts on the signal of the 21st bit of a counter(about 80 ms). when the 3rd bit of thr timer turns to a 1(after 240 ms) i want the dots to stop outputting. the problem is that when i put in code to say if the bit turns to a 1 then stop, it will not work at all.should i have a reset for the timer or is the code wrong?

any help would be greatly appreciatedl.




process(cnt(21)) --code to initialise the timer
begin

if cnt(21)' event and cnt(21) = '1' then
timer <= timer + 1;

end if;
end process;


process(clk)
begin



if clk'event and clk='1' then

cnt <= cnt + 1;


tone_temp <= cnt(16);
dash_temp <= cnt(24);
dot_temp <= cnt(22);

end if;



if scancode = "00011011" and clk'event and clk='1' then --scancode for letter S

sig_dot <= tone_temp and dot_temp;

-- dash <= cnt(24) ; --pin 4
-- tone <= cnt(16) ; --pin 25

while timer(2) <= '0' loop
enable <= '1';
end loop;
dash <= sig_dot and enable;
--if timer(2) <= '1' then enable <= '0' -- when this code is input it stops working


--dash <= sig_dot and enable;


--if timer(2) <= '1' then sig_dot <= '0';


end if;

-- end if;
end process;


process(clk)
begin



if scancode = "01000100" and clk'event and clk='1' then --scancode for letter O

sig_dash <= tone_temp and dash_temp;

if timer(3) <= '1'then
tone <= sig_dash;

end if;
end if;
end process;



end architecture;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top