I'm having inconsistent times on my timer, can be anywhere from 300ms - 4 seconds, what could be causing this?
The code logic looks good to me but the oscope shows different times almost everytime I run it. Here's how I set up the code for the timer. I'm using an arduino as a clock at about 256Hz. The timer should go off at 4 seconds not any sooner like it is.
library ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;
constant C_2SEC_TC : integer := 1023;
signal tmr_cnt : std_logic_vector(11 downto 0) := (others => '0');
signal tc_2sec : std_logic;
begin
-- counter for internal timer
second_cntr_proc: process(CLK)
begin
if (rising_edge(CLK)) then
tmr_cnt <= tmr_cnt + 1;
if (tc_2sec='1') then
tmr_cnt <= (others => '0');
end if;
end if;
end process second_cntr_proc;
tc_2sec <= '1' when tmr_cnt = C_2SEC_TC else '0';
I initialize a pin high and when tc_2sec goes high I set that pin low. The high time of that pin isn't always the same.