打印

串口程序的发送端,跪求指点迷津

[复制链接]
1234|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
beniron|  楼主 | 2008-7-16 16:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我调试串口模块的发送端,让他一直发送一个常数,为什么接受不到啊?
我的时钟周期已经设置为1/9600(=104us).没有校验位。我已经弄了好几天了还是没有结果。刚刚学verilog,跪求高人指点。谢谢
module transfer(clk,rst/*,send_enable*/,txd,send_over/*,send_bus*/);
input clk,rst/*,send_enable*/;
//input[7:0] send_bus;
output txd,send_over;
reg txd;
reg send_over;//when finish sending,set send_over to 1,otherwise send_over is 0
wire[7:0] send_bus;
wire send_enable;
parameter[2:0] IDLE=3'B001;
parameter[2:0] SEND=3'B010;
parameter[2:0] STOP=3'B100;

reg[2:0] state;
reg[2:0] count;
reg[7:0] buffer;
assign send_bus=8'b01010101;//为了测试,我把总线上放固定的常数,希望接受到这个常数。
assign send_enable=1'b1;

always @(posedge clk or negedge rst)
begin
  if(!rst)
    begin
      state<=IDLE;
      count<=0;
      send_over<=0;
      buffer<=8'b0;
      txd<=1;
    end
  else
    begin
      case(state)
        IDLE:
          begin
            if(send_enable) 
              begin
           txd<=0;
                state<=SEND;
              end
            else
              begin
                state<=IDLE;
                txd<=1;  
              end
             buffer<=send_bus;
             count<=0;
             send_over<=0;
              end
        SEND:
          begin
            txd<=buffer[count];
            if(count==7)
              begin
                count<=0;
                state<=STOP;
              end
            else
              begin
                count<=count+1;
                state<=SEND;
              end
          end
        STOP:
          begin
            txd<=1;
            state<=IDLE;
            send_over<=1;
                      end
        default:
          begin
            state<=IDLE;
            txd<=1;
            send_over<=0;
          end
      endcase
    end
end

endmodule

相关帖子

沙发
至尊宝| | 2008-7-17 17:22 | 只看该作者

拿示波器看看。

使用特权

评论回复
板凳
超导体88| | 2008-8-14 11:39 | 只看该作者

用逻辑分析仪啊

逻辑分析仪里面可以直接分析UART协议的,很方便,马上就可以看到错误在哪里

使用特权

评论回复
地板
armecos| | 2008-8-15 09:02 | 只看该作者

仿真看下时序,

起始位、数据位、停止位正确吗?采样脉冲能采到中间位置吗?特别是起始位、停止位,如果这两个位置错,你将收不到数据,如果数据位错,你至少应该能收到乱码。

还有你的驱动能力、串口线线序、是否开焊等都会收不到串口数据。

更多内容,详见:
《培训系列“丛书”》
www.armecos.com
-----------------------------------
More details, see:
《"Series Books" of Training》
www.armecos.com

使用特权

评论回复
5
dynameo| | 2008-8-23 17:28 | 只看该作者

提醒

 首先,你看看你的仿真图形对不对,如果这个都不对,还谈什么测试?
如果对的,往下,看你用什么测试,用什么线?
如果你通过串口线在电脑上看数据,你必须把FPGA输出的电平转换为RS232电平,这个可以通过MAX232转,很同意,然后你要确保你的芯片工作,关于测试方法,你可以测试一下升压器升压的电压是多少来确定,具体自己找资料。这个是一个过程。

特别说一下串口线的问题,串口线又直通和交叉两种连接方式,你要测试一下你的串口线是哪种,假如设计用直通来测试,你的线是交叉的,测试方法很简单的,自己找资料。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

1

帖子

0

粉丝