# FPGA able to send data, but unable to receive data. (UART - RS232)

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 [7:0] RxD_data;
reg [7:0] 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?

## migrated from embedded.stackexchange.comJun 9 '14 at 20:47

• 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? – Bart van Ingen Schenau May 22 '14 at 6:33
• @BartvanIngenSchenau yeah I already tried the reverse bit option from my rs232 program. Also, using a symmetrical value like 0x55 didn't work. – thejohnny May 22 '14 at 13:59
• I have added your explanation to the question. – Bart van Ingen Schenau May 22 '14 at 14:01
• Are you sure your LED isn't turning on for a few milliseconds then turning off after completion? – Zack May 22 '14 at 14:13
• @Zack yes I'm positive. The transmission can last as long as i want and i let it go for a long while. – thejohnny May 22 '14 at 14:21

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.

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.