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
一周热门 更多>