完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
MAX6675是不是先读D0位,后读高位,我改写的老师的程序,先读低位,依次右移到高位,这样是不是读出来的数据是不是反了,求指导,不太明白,编译警告也是,哪里需要修改
,求大神指导 //********************根据MAX6675测温方式,编写测量两路温度程序***************** /*0℃~+1024℃的测温范围,12位0.25℃的分辨率,MCU使CS变低并提供时钟信号给SCK,由SO 读取测量结果CS变低将停止任何转换过程;CS变高将启动一个新的转换过程。一个完整串行接口 读操作需16个时钟周期,在时钟的下降沿读16个输出位,第1位和第I5位是一伪标志位,并总为0。 第14位到第3位为以MSB到LSB顺序排列的转换温度值;第2位平时为低,第0位为三态,第3-4位为小数位*/ module T_measure(USEC_FLAG,SEC_FLAG,T1_SO,T2_SO,DISP_T1,DISP_T2); reg T1_CS,T1_SCK,T2_CS,T2_SCK; reg[15:0] T1_data,T2_data; reg[9:0] T_counter; reg[15:0] DISP_T1,DISP_T2; input USEC_FLAG,SEC_FLAG; input T1_SO,T2_SO; //output T1_CS,T1_SCK,T2_CS,T2_SCK; output[15:0] DISP_T1,DISP_T2; always@( posedge USEC_FLAG or negedge SEC_FLAG) begin if(!SEC_FLAG) begin T_counter[9:0]=0; end else T_counter[9:0]=T_counter[9:0]+1'b1; end always@(T_counter[9:0]) begin if((T_counter[9:0]>10'h001)&&(T_counter[9:0]<10'h084)) begin T1_CS=0; T2_CS=0; end else begin T1_CS=1; T2_CS=1; end case(T_counter[9:0]) 10'h005: begin T1_SCK=1; T2_SCK=1; end 10'h00d: begin T1_SCK=1; T2_SCK=1; end 10'h015: begin T1_SCK=1; T2_SCK=1; end 10'h01d: begin T1_SCK=1; T2_SCK=1; end 10'h025: begin T1_SCK=1; T2_SCK=1; end 10'h02d: begin T1_SCK=1; T2_SCK=1; end 10'h035: begin T1_SCK=1; T2_SCK=1; end 10'h03d: begin T1_SCK=1; T2_SCK=1; end 10'h045: begin T1_SCK=1; T2_SCK=1; end 10'h04d: begin T1_SCK=1; T2_SCK=1; end 10'h055: begin T1_SCK=1; T2_SCK=1; end 10'h05d: begin T1_SCK=1; T2_SCK=1; end 10'h065: begin T1_SCK=1; T2_SCK=1; end 10'h06d: begin T1_SCK=1; T2_SCK=1; end 10'h075: begin T1_SCK=1; T2_SCK=1; end 10'h07d: begin T1_SCK=1; T2_SCK=1; end default: begin T1_SCK=0; T2_SCK=0; end endcase end always@(negedge T1_SCK) begin T1_data<=(T1_data<<1); T1_data[0]<=T1_SO; end always@(negedge T2_SCK) begin T2_data<=(T2_data<<1); T2_data[0]<=T2_SO; end always@(posedge T1_CS) begin DISP_T1[11:8] = 4'b1110;// (T1_data[14:5]/100==4'b0000)?4'b1110:(T1_data[14:5]/100);显示断码字符t,意思为温度 DISP_T1[7:4] = (T1_data[14:5]%100)/10;//十位 DISP_T1[3:0] = T1_data[14:5]%10;//个位 //if(T1_data[14:5]>80)led[1]=0; //温度报警 置指示灯 // else led[1]=1; end always@(posedge T2_CS)// or negedge rst) begin //if(!rst)led[1]=1'b1; //复位 避免开机时温度报警指示灯闪一下 //else begin DISP_T2[11:8] = (T2_data[14:5]/7'd100==4'b0000)?4'b1110:(T2_data[14:5]/7'd100);//判断百位是否为0,为零则显示t,不为0则显示具体数字 DISP_T2[7:4]=(T2_data[14:5]%7'd100)/4'd10;//十位 DISP_T2[3:0]=T2_data[14:5]%4'd10;//个位 //if(T2_data[14:5]>80)led[1]=0; //温度报警 置指示灯 // else led[1]=1; end endmodule 编译栏:Warning (10230): Verilog HDL assignment warning at T_measure.v(150): truncated value with size 32 to match size of target (4) Warning (10230): Verilog HDL assignment warning at T_measure.v(151): truncated value with size 32 to match size of target (4) Warning (10230): Verilog HDL assignment warning at T_measure.v(161): truncated value with size 10 to match size of target (4) Warning (10230): Verilog HDL assignment warning at T_measure.v(162): truncated value with size 10 to match size of target (4) Warning (10230): Verilog HDL assignment warning at T_measure.v(163): truncated value with size 10 to match size of target (4) Warning (10034): Output port "DISP_T1[15]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T1[14]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T1[13]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T1[12]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T2[15]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T2[14]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T2[13]" at T_measure.v(13) has no driver Warning (10034): Output port "DISP_T2[12]" at T_measure.v(13) has no driver Warning: Reduced register "DISP_T1[11]~reg0" with stuck data_in port to stuck value VCC Warning: Reduced register "DISP_T1[10]~reg0" with stuck data_in port to stuck value VCC Warning: Reduced register "DISP_T1[9]~reg0" with stuck data_in port to stuck value VCC Warning: Reduced register "DISP_T1[8]~reg0" with stuck data_in port to stuck value GND Warning: Output pins are stuck at VCC or GND Warning: Pin "DISP_T1[8]" stuck at GND Warning: Pin "DISP_T1[9]" stuck at VCC Warning: Pin "DISP_T1[10]" stuck at VCC Warning: Pin "DISP_T1[11]" stuck at VCC Warning: Pin "DISP_T1[12]" stuck at GND Warning: Pin "DISP_T1[13]" stuck at GND Warning: Pin "DISP_T1[14]" stuck at GND Warning: Pin "DISP_T1[15]" stuck at GND Warning: Pin "DISP_T2[12]" stuck at GND Warning: Pin "DISP_T2[13]" stuck at GND Warning: Pin "DISP_T2[14]" stuck at GND Warning: Pin "DISP_T2[15]" stuck at GND 本帖被以下淘专辑推荐:
|
|
相关推荐
1个回答
|
|
MAX6675是從高位網低位輸出的,你看下MAX6675的數據手冊就一幕鳥然了。如果沒有,回貼可以給你一份中文的。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1404 浏览 1 评论
1198 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1407 浏览 0 评论
912 浏览 0 评论
2214 浏览 0 评论
1424 浏览 34 评论
5610 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-21 21:48 , Processed in 0.603884 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号