kidi3
Full Member level 1
I am at the moment trying to implement a PWM signal for controlling a servo motor..
The problem is though, is my PWM is not getting generated..
I don't how i managed to do it, but earlier i had an PWM up an running, but it seems something happened to the code, which doesn't not make sense..
here is it
I have no idea on why it doesn't work.. Any help would be appreciated.
- - - Updated - - -
Nothing is wrong with the FPGA itself... it is the code something is wrong with.
The problem is though, is my PWM is not getting generated..
I don't how i managed to do it, but earlier i had an PWM up an running, but it seems something happened to the code, which doesn't not make sense..
here is it
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity pwm is
Port
(
CLK : in STD_LOGIC;
PWM : out std_logic
);
end pwm;
architecture Behavioral of pwm is
signal counter: integer range 0 to 1000000;
begin
prescaler: process(clk)
begin
if rising_edge(clk) then
if counter < 1000000 then
counter <= counter + 1;
else
counter <= 0;
end if;
end if;
end process;
pwm_s: process(counter)
begin
if counter < 10000 then
pwm <= '1';
else
pwm <= '0';
end if;
end process;
end Behavioral;
I have no idea on why it doesn't work.. Any help would be appreciated.
- - - Updated - - -
Nothing is wrong with the FPGA itself... it is the code something is wrong with.