- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am fighting with temperature sensor on DE3 board. I need to read temperature of FPGA and I do not want to use NIOS. According to manual, MAX1619 has SMBus interface and I should send very simple sequence to get temperature:
<Start> <Address=7'b0011000> <WR=0> <Ask> <Data=8'h01> <Ask> <Start> <Address=7'b0011000> <RD=1> <Ask> <Reading data> <Stop>
I implemented it on verilog as following:
Code:
////////// CLOCK //////////
output CLK_OUT;
input EXT_CLK;
input OSC1_50;
input OSC2_50;
input OSC_BA;
input OSC_BB;
input OSC_BC;
input OSC_BD;
////////// SEG7 //////////
output [6:0] HEX0;
output HEX0_DP;
output [6:0] HEX1;
output HEX1_DP;
////////// MAX1619 (TEMPERATURE SENSOR) //////////
output TEMP_CLK;
inout TEMP_DATA;
input TEMP_INTn;
//...
// Temperature sensor
reg [7:0] Display;
reg [31:0] TempTimer;
reg [6:0] TempCounter;
reg [127:0] TempCLK, TempOUT, TempRES, TempDIR;
always @(posedge OSC1_50) TempTimer<=TempTimer+1; // 50MHz clock
initial
begin
TempCounter=0;
// S ADDRESS WR ASK COMMAND ASK S ADDRESS RD ASK DATA P
TempCLK=128'b11110_010_010_010_010_010_010_010__010_010__010_010_010_010_010_010_010_010__010_110__010_010_010_010_010_010_010__010_010__010_010_010_010_010_010_010_010__001111111111111;
TempDIR=128'b11111_111_111_111_111_111_111_111__111_000__111_111_111_111_111_111_111_111__000_111__111_111_111_111_111_111_111__111_000__000_000_000_000_000_000_000_000__111111111111111;
TempOUT=128'b11100_000_000_111_111_000_000_000__000_000__000_000_000_000_000_000_000_111__000_100__000_000_111_111_000_000_000__111_000__000_000_000_000_000_000_000_000__111101111111111;
// 76543 210 987 654 321 098 765 432 109 876 543 210 987 654 321 098 765 432 109 876 543 210 987 654 321 098 765 432 109 876 543 210 987 654 321 098 765 432109876543210;
// 22222 222 111 111 111 100 000 000 009 999 999 999 888 888 888 877 777 777 776 666 666 666 555 555 555 544 444 444 443 333 333 333 222 222 222 211 111 111110000000000;
end
always @(posedge TempTimer[11]) // 50MHz/4096=12KHz
begin
TempCounter=128-TempTimer[18:12];
TEMP_CLK=TempCLK[TempCounter];
if(TempDIR[TempCounter]==1'b0)
TempRES[TempCounter]=TEMP_DATA;
else
TEMP_DATA=TempOUT[TempCounter];
end
always @(posedge TempTimer[11]) // here I print the temperature on 7-seg display
begin
Display={TempRES[37], TempRES[34], TempRES[31], TempRES[28], TempRES[25], TempRES[22], TempRES[19], TempRES[16]};
case(Display/100)
2'h0: begin HEX0_DP=1; HEX1_DP=1; end
2'h1: begin HEX0_DP=0; HEX1_DP=1; end
2'h2: begin HEX0_DP=0; HEX1_DP=0; end
2'h3: begin HEX0_DP=0; HEX1_DP=0; end
endcase
case(Display%10)
4'h0: HEX0=~63;
4'h1: HEX0=~6;
4'h2: HEX0=~91;
4'h3: HEX0=~79;
4'h4: HEX0=~102;
4'h5: HEX0=~109;
4'h6: HEX0=~125;
4'h7: HEX0=~7;
4'h8: HEX0=~127;
4'h9: HEX0=~111;
4'ha: HEX0=~119;
4'hb: HEX0=~124;
4'hc: HEX0=~57;
4'hd: HEX0=~94;
4'he: HEX0=~121;
4'hf: HEX0=~113;
endcase
case((Display/10)%10)
4'h0: HEX1=~63;
4'h1: HEX1=~6;
4'h2: HEX1=~91;
4'h3: HEX1=~79;
4'h4: HEX1=~102;
4'h5: HEX1=~109;
4'h6: HEX1=~125;
4'h7: HEX1=~7;
4'h8: HEX1=~127;
4'h9: HEX1=~111;
4'ha: HEX1=~119;
4'hb: HEX1=~124;
4'hc: HEX1=~57;
4'hd: HEX1=~94;
4'he: HEX1=~121;
4'hf: HEX1=~113;
endcase
end
hence I defined 4 x 128 bit arrays: TempCLK, TempOUT, TempRES, TempDIR, so that
- TempCLK[i] what I will send to Clock of SMBus,
- TempDIR[i]==1 then I am writing to the SMBus, TempDIR[i]==0 then I am reading form
- TempOUT[i] what I should send to SMBus if I am writing,
- TempRES[i] what I am reading from SMBus if I am reading.
Please, advise me what I did wrong, I played a lot, but I still cannot get temperature from this sensor.
Thank you
Sincerely,
Ilghiz
Link Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page