5
\$\begingroup\$

I have a DE0-nano FPGA board and I am trying to establish a serial connection with my PC.

I am using the RS232 implementation from here: http://www.fpga4fun.com/SerialInterface.html

I have tested sending from the FPGA, and it worked perfectly. However, when I try to send to the FPGA, it seems to not be working.

Here is my verilog code:

module Learning(
    input clk,
    input RxD,
     output LED
);

wire RxD_data_ready;
wire [7:0] RxD_data;
reg [7:0] data;

async_receiver RX(.clk(clk), .RxD(RxD), .RxD_data_ready(RxD_data_ready), .RxD_data(RxD_data));

always @(posedge clk) if(RxD_data_ready) data <= RxD_data;

assign LED = (data == 8'h24);

endmodule

Basically I have designed it such that a specific LED on my board turns on while I am sending the hexadecimal value 24. Since I am sending this value at a very high frequency I do expect the LED to remain on for the whole transmission. However, nothing is happening. It stays off.

I already tried the reverse bit option from my rs232 program. Also, using a symmetrical value like 0x55 didn't work.

What could be the issue?

\$\endgroup\$

migrated from embedded.stackexchange.com Jun 9 '14 at 20:47

  • 1
    \$\begingroup\$ Just a few random thoughts: could it be a bit-ordering issue (you send MSB first, but read LSB first or vice versa)? What happens if you test with bitpatterns like 0x00, 0xFF, 0x55 or 0xAA? \$\endgroup\$ – Bart van Ingen Schenau May 22 '14 at 6:33
  • \$\begingroup\$ @BartvanIngenSchenau yeah I already tried the reverse bit option from my rs232 program. Also, using a symmetrical value like 0x55 didn't work. \$\endgroup\$ – thejohnny May 22 '14 at 13:59
  • \$\begingroup\$ I have added your explanation to the question. \$\endgroup\$ – Bart van Ingen Schenau May 22 '14 at 14:01
  • \$\begingroup\$ Are you sure your LED isn't turning on for a few milliseconds then turning off after completion? \$\endgroup\$ – Zack May 22 '14 at 14:13
  • \$\begingroup\$ @Zack yes I'm positive. The transmission can last as long as i want and i let it go for a long while. \$\endgroup\$ – thejohnny May 22 '14 at 14:21
3
\$\begingroup\$

Since you can't debug Verilog the way you can with C and a microcontroller, you need to take incremental debugging steps...

  • If you just assign LED 1, does the LED turn on and stay on?
  • Is data being read at all? Maybe just toggle the LED if any character comes in
  • Make sure these work and them move on to 0x24

My advice is to take baby steps when debugging, especially with a hardware description language.

\$\endgroup\$
2
\$\begingroup\$

I managed to figure it out.

Turns out the particular RS232 module I'm using works optimally with an input clock of 25MHz. My FPGA main clock is 50MHz, so I simply ran it through a 1 bit divider to obtain a 25MHz clock. Using this as my UART clock worked perfectly.

I also used the 8 LEDs to display the 8 bits of data being received, which helped immensely.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.