Necesito generar 500Hz desde la frecuencia de reloj de 50MHz. Ya lo tengo. Mi problema aquí es cómo se debe ajustar el código si quiero cambiar el ciclo de trabajo al 10%?
Gracias.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity FreqDivider500Hz is
port(
clock : in STD_LOGIC; -- 50 Mhz
clear : in STD_LOGIC;
freq1 : out STD_LOGIC
);
end FreqDivider500Hz;
architecture Behavioral of FreqDivider500Hz is
signal adjfreq: STD_LOGIC_VECTOR(15 downto 0) := "0000000000000000";
signal adjclock : std_logic := '0';
begin
freq1 <= adjclock;
countClock: process(clock,clear)
begin
if (clear = '1') then
adjfreq <= "0000000000000000";
elsif(clock'event and clock = '1') then
-- Flip a the output once every 50,000 cycles (1kHz)
-- to give a 500Hz output with 50% duty cycle
if (adjfreq = "1100001101010000") then
adjfreq <= "0000000000000000";
if adjclock <= '0' then
adjclock <= '1';
else adjclock <= '0';
end if;
else
adjfreq <= adjfreq+1;
end if;
end if;
end process;
end Behavioral;