module testc (CLOCK_50, KEY, UART_RXD, LEDR);
parameter IDLE = 1'b0;
parameter RECEIVING = 1'b1;
input CLOCK_50, UART_RXD;
input [0:0] KEY;
output [7:0] LEDR;
wire [7:0] RxData;
reg shift;
reg [1:0] state, nextstate;
reg [3:0] bitcounter;
reg [3:0] samplecounter;
reg [12:0] counter;
reg [10:0] rxshiftreg;
reg clear_bitcounter, inc_bitcounter, inc_samplecounter, clear_samplecounter;
wire reset;
assign reset = KEY[0];
assign RxData = rxshiftreg[8:1];
assign LEDR = RxData;
always @ (posedge CLOCK_50)
begin
if (!reset)
begin
state <= IDLE;
bitcounter <= 0; counter <= 0;
samplecounter <= 0;
end
else
begin
counter <= counter+1;
if (counter>=1736)
begin
counter<=0;
state<=nextstate;
if (shift)
rxshiftreg<={UART_RXD, rxshiftreg[10:1]};
if (clear_samplecounter)
samplecounter<=0;
else if (inc_samplecounter)
samplecounter<=samplecounter+1;
if (clear_bitcounter)
bitcounter <=0;
if (inc_bitcounter)
bitcounter<=bitcounter+1;
end
end
end
always @ (state or UART_RXD or bitcounter or samplecounter)
begin
shift = 0;
clear_samplecounter = 0;
inc_samplecounter = 0;
clear_bitcounter = 0;
inc_bitcounter = 0;
case (state)
IDLE:begin
if (UART_RXD)
nextstate = IDLE;
else begin
nextstate = RECEIVING;
clear_bitcounter = 1;
clear_samplecounter = 1;
end
end
RECEIVING:begin
if (samplecounter == 1) shift = 1;
if (samplecounter == 3) begin
if (bitcounter == 10) begin
nextstate = IDLE;
end
inc_bitcounter = 1;
clear_samplecounter = 1;
end
else inc_samplecounter = 1;
end
endcase
end
endmodule
This is the verilog module i am using to get my rxdata ... When i connect the tx pin of the sensor to the rx pin of the de2 the leds just keep blinking without pattern and also the rxd led on the de2 keeps blinking which means it is getting the data. I give a outside 5v source to the sensor and ground the 5th pin of the rs232
If anyone can help it qould be great