PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : DS1722 SPI-Thermometer-IC ansprechen...



stefan_Z
07.10.2007, 15:32
Hallo!

Ich plage mich hier mit dem DS1722 rum, irgendwie mag er mich nicht.
Das Datenblatt findet Ihr hier: http://datasheets.maxim-ic.com/en/ds/DS1722.pdf
Die wichtigsten Infos habe ich mal ins Listing reingeschrieben, sollte eigentlich alles stimmen.
Die SPI-Optionen habe ich schon alle getestet, hilft nicht.

Die Ausgaben vom SPI sind immer alle 11111111.

hat jemand ne Idee?
Der Chip sollte bis 5 MHz SPI können.


$regfile = "m8def.dat"
$crystal = 8000000

$hwstack = 32 'default use 32 for the hardware stack
$swstack = 10 'default use 10 for the SW stack
$framesize = 40 'default use 40 for the frame space

'******* BYTE-ORDER *******
'SPI MSB first / 3-Wire LSB first
Config Spi = Hard , Interrupt = On , Data Order = Msb , Master = Yes , Polarity = High , Phase = 0 , Clockrate = 4 , Noss = 0
Spiinit

'******* TEMPERATURE FORMAT *******
'MSB LSB MSB LSB
' 1 2 3 4 5 6 7 8 02h 1 2 3 4 5 6 7 8 01h
' S 6 5 4 3 2 1 0 -1 -2 -3 -4 0 0 0 0
Dim Temp_lsb As Byte
Dim Temp_msb As Byte
Dim Config_in As Byte
Dim Befehl As Byte

'******* R/W ADDRESSES *******
'Read Address Write Address Active Register
' 00h 80h Configuration
' 01h no access Temperature LSB
' 02h no access Temperature MSB
Const Write_config = &H80
Const Read_config = &H00
Const Read_temp_lsb = &H01
Const Read_temp_msb = &H02

'******* CONFIGURATIONS *******
'Configuration/Statur Register
'MSB LSB
' 1 2 3 4 5 6 7 8
' 1 1 1 1-S R2 R1 R0 SD

' (1-S) 1SHOT - When set, one conversion will be made and stored in output-registers. Bit will reset to 0 then.
' (R0-R1) TERMO-RESOLUTION
' R2 R1 R0 Resolution Max Conversion Time
' 0 0 0 8-Bit 0.075s
' 0 0 1 9-Bit (Default) 0.15s
' 0 1 0 10-Bit 0.3s
' 0 1 1 11-Bit 0.6s
' 1 X X 12-Bit 1.2s
' (SD) SHUTDOWN-BIT
' 0 > continuous conversion
' 1 > Last result saved, power-down-mode (default)
Const Config_9bit_cont_conv = &B11100010
Const Config_12bit_cont_conv = &B11101000

'Print initial variable-values
Print
Print "-------------"
Print "LSB " ; Bin(temp_lsb)
Print "MSB " ; Bin(temp_msb)
Print "CFG " ; Bin(config_in)

'Initiate configuration-write
Befehl = Write_config
Spiout Befehl , 1

'Write config-register
Befehl = Config_9bit_cont_conv
Spiout Befehl , 1

'Initiate configuration-read
Befehl = Read_config
Spiout Befehl , 1

'Save configuration to Variable
Spiin Config_in , 1

Waitms 500

Do
'Request Temperature LSB
Befehl = Read_temp_lsb
Spiout Befehl , 1
'Save to Variable
Spiin Temp_lsb , 1

'Request Temperature MSB
Befehl = Read_temp_msb
Spiout Befehl , 1
'Save to Variable
Spiin Temp_msb , 1

Print "LSB " ; Bin(temp_lsb)
Print "MSB " ; Bin(temp_msb)
Print "CFG " ; Bin(config_in)
Wait 2
Loop

End

stefan_Z
08.10.2007, 18:46
Hat keiner ne Idee?