lingcw 发表于 2011-5-23 20:02:18

大家帮忙看看嘞 CPLD产生115200波特率问题

parameter ClkFrequency = 25000000;        // 25MHz
parameter Baud = 115200;
parameter RegisterInputData = 1;        // in RegisterInputData mode, the input doesn't have to stay valid while the character is been transmitted

// Baud generator
parameter BaudGeneratorAccWidth =16;
reg BaudGeneratorAcc;
`ifdef DEBUG
wire BaudGeneratorInc = 17'h10000;
`else
wire BaudGeneratorInc = ((Baud<<(BaudGeneratorAccWidth-4))+(ClkFrequency>>6))/(ClkFrequency>>5);
`endif

wire BaudTick = BaudGeneratorAcc;
wire TxD_busy;
always @(posedge clk) if(TxD_busy) BaudGeneratorAcc <= BaudGeneratorAcc + BaudGeneratorInc;
这段是25MHZ产生115200波特率的代码 如果改成30MHZ 如何修改使产生115200的波特率呢?跪求指导

lingcw 发表于 2011-5-23 20:04:47

回复【楼主位】lingcw
-----------------------------------------------------------------------

修改个地方,正确的应为:((Baud<<(BaudGeneratorAccWidth-4))+(ClkFrequency>>5))/(ClkFrequency>>4);

lingcw 发表于 2011-5-28 12:03:36

回复【1楼】lingcw
-----------------------------------------------------------------------

哎呀自个弄明白了 就是分频 求步进值

denike 发表于 2011-5-31 17:54:13

fpga4fun上的 呵呵 挺不错的程序

lingcw 发表于 2011-6-3 22:41:34

回复【3楼】denike
-----------------------------------------------------------------------

是啊我现在也发现了。。。。。
页: [1]
查看完整版本: 大家帮忙看看嘞 CPLD产生115200波特率问题