need help with timing (one-shot) & switch debouncing

Joined
Oct 5, 2007
Messages
6
Reaction score
0
Hello again, I have two questions actually...

1) What is a good way to code a switch debouncer? I'm stuck as far as having a single bouncy switch signal and I have to take care of it inside a CPLD. I tried clocking the input into a signal, and this worked fine, but I have to have the frequency up to 32Hz which eats flip-flops for other things. is there a better way so I can slow down my clock and save space?


2)I've been trying to implement some code that gives me a variable one-shot. So far I have:

Code:
Process (CLK, reset)
	variable CNT: integer range 0 to 319;
begin
	if (reset = '0') then --power on reset active = timer inactive
		timer <= '1'; 
		CNT := 0;

	elsif (rising_edge(CLK)) then
		if (CNT = SETCNT - 1) then --count has reach goal
			cnt := 0;
			timer <= '0';
		else
			timer <= '1';
			cnt := cnt + 1;
		end if;
	end if;	
end process;

where elsewhere in the code i specify how long I want the pulse to last (SETCNT). This works fine if timers are constantly cycling, but I need it to stay low until a state change. I know I'd need to take the cnt := 0 line out of the line where timer goes low...but I'm not sure how I can set it to zero later. The reset is a power-on reset. Any help would be much appreciated
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top