Hello everyone !
This is my first post on this forum. I hope this topic is in the right place..
So i have this project in which i use the UART serial interface between my Nexys 3 (Spartan 6) FPGA and my PC.
I transfer "large" files ( like 1 MB ) to it and i needed a way to detect when the FPGA would stop receiving data(from UART).
Pretty simple..right ?
I used the fact that the Rx is '1' when inactive and '0' when it starts transmitting data (START bit is '0').
So i decided to increment a Counter when Rx = '1' and reset it to '0' when Rx = '0'.
If the counter reaches a certain value (depends on the sample rate) then i can say the UART is innactive ( Rx was '1' for a long time)
But it doesn't work...
The Baud Rate i use = 781250 and the transfer of data works flawlessly ( i sample Rx with a clock = 12,5 Mhz, 16 times per bit transfered) but i don't manage to do this inactivity detection circuit to work.
I tested a lot of other baud rates : (sampling 2 times per bit, so the clock frequency = 2 x Baud Rate, it should be enough)
300 Works !
9600 Works !
19200 Works !
57600 Nope..
781250 Nope..
This is the code, clk_s is twice the frequency of the Baud Rate, so i can sample each bit 2 times.
So in maximum 20 clock cycles i should encounter at least one zero (the start bit);
I put x"0030" = 48 just for good measure...
process(clk_s, rx)
begin
if rx = '0' then
UART_innactive <= '0';
count <= x"0000";
elsif rising_edge(clk_s) then
if count = x"0030" then
UART_innactive <= '1';
count <= x"0000";
else
count <= std_logic_vector (unsigned(count) + 1);
end if;
end if;
end process;
So.. i suspect a timing problem coming wither from my bad code or the FPGA.
The led i connected UART_innactive to just blinks very rapidly
Thank you