rs-232 trouble

Hi

I've been coding a rs-232 rx/tx module. after some hardwork, it's all working fine for timeing and everything (rx/tx) -- except one thing-- whenever I reprogram the FPGA, the first byte received always has 0x80 bigger than what was actually sent. everything works fine afterward. I'm using comDebug.

I don't use flow control, and only RXD,TXD lines.

Any suggestion? Thanks.

Reply to
Paul
Loading thread data ...

What does in mean *the first bite received*? After what? If after power-on the revise async resets in appropriate process. If all the bytes are ORed with '1' then you catch the stop bit. Please remember two things when programming rs232: - sample bits at the middle of bit slice; and - pass to receiving next bit at the middle of stop bit.

Reply to
valentin tihomirov

Do you use an "async_rst" signal to reset the FPGA after configuration?

If not, be careful as the registers start at "0" regardless of the input levels.

Could you share your code so that we can take a look? You can also find some sample code here

formatting link

Jean

Reply to
Jean Nicolle

There is no buffer right now, so it cannot receive continuous bytes. working on that when I got this "first byte" problem figured out.

`define LENGTH (50000000/38400) module top2(clk,RXD,TXD,led0,led1); input clk; input RXD; output TXD,led0,led1;

reg [1:0] s1;

reg [7:0] char_w; wire [7:0] char_r; reg go_r,go_w; send qq1 (clk,char_w,go_w,ok_w,TXD); recv qq2 (clk,char_r,go_r,ok_r,RXD); assign led0=~char_w[6]; assign led1=~char_w[7];

always @(posedge clk) begin case (s1) 0: begin s1

Reply to
Paul

Hi

did I mention that a Maxim MAX3386E RS232 voltage converter was between fpga and the connector on my board. maybe it has something to do with it.

also, after some debugging. I found out a few facts:

  1. if I send 0x00 from comDebug, the last 2 MSB's are correctly received. (from LED lights.) the echoed value received from comDebug is 0x80.

  1. if I send 0x10 from comDebug, the last 2 MSB's are correctly received. (from LED lights.) the echoed value received from comDebug is 0x90.

  2. if I send 0x20 from comDebug, the last MSB is correctly received. but the 6th bit was wrong. (from LED lights.) the echoed value received from comDebug is 0xA0.

  1. if I send 0x40 from comDebug, the 6th and 7th got switched. (from LED lights.) the echoed value received from comDebug is 0xC0.

  2. if I send 0x80 , the echoed value received from comDebug is 0x80. (however, the led indicate I received 0x00.)

so from this I can conclude there is something wrong in both the send and recv modules -- for the first byte. strangely every byte afterward is OK.

Reply to
Paul

When I was debugging my modules I did it separately. Send a stream out of UART, make sure it is working prperly. Make sure that receiver is working by observing debug pins on PLD. Revise quartz rate and divider.

Do you synchronize Rx input? I don't and everything working OK; however, there are multibit counters depending on the input, thus I think it should.

Reply to
valentin tihomirov

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.