Hello,
The code bin file are not understandable.
'8mhz+Xtal /8 off Attiny44 Fuse FF DF FF
'8mhz+Xtal /8 Attiny44 Fuse 7F DF FF
'8mhz intRC /8 off Attiny44 Fuse E2 DF FF
'8mhz intRC /8 Attiny44 Fuse 62 DF FF
DDRA = 0xff 'Port A all outputs, TrisA=0x00 for PIC
Define CLOCK_FREQUENCY = 8
Define SPI_CS_REG = PORTA 'Set up ports for SPI
Define SPI_CS_BIT = 5 'CS port
Define SPI_SCK_REG = PORTA
Define SPI_SCK_BIT = 4 'Clock
Define SPI_SDO_REG = PORTA
Define SPI_SDO_BIT = 6 'Data out
Symbol signal = PORTB.2 'port for DHT22 signal
Dim humin As Word 'Relative Humidity
Dim tempin As Word 'Temperature
Dim check As Byte 'used to calculate humidity and temp
Dim l As Byte 'calculated temp
Dim dew As Byte 'calculated humidity
Dim sign As Byte 'minus temperature
Dim hsign As Byte 'minus dewpoint
Dim c As Byte 'bit collector
Dim b(32) As Byte 'used to process data
Dim t As Byte 'temperature tens
Dim u As Byte 'temperature units
Dim th As Byte 'dew point tens
Dim uh As Byte 'dew point units
Dim bi As Byte 'bit in
Dim x As Byte 'calculation bit
SPIPrepare 'Set up 7 segment LEDs
SPICSOn
SPISend 0xfc 'Shutdown Mode
SPISend 0xff 'Normal
SPICSOff
WaitMs 10
SPICSOn
SPISend 0xff 'Test On, All segments ON
SPICSOff
WaitMs 10
SPICSOn
SPISend 0xfe 'Test Off
SPICSOff
WaitMs 10
SPICSOn
SPISend 0xfa 'intensity
SPISend 0xf7 '13/32
SPICSOff
WaitMs 10
SPICSOn
SPISend 0x0b 'scan limit
SPISend 0x07 '7 Eight 7 segment LEDs
SPICSOff
loop:
WaitMs 1500 'wait for initial response from DHT22
DDRB.2 = 1 'data pin to output. TrisB.2 = 0 for PIC
signal = 0 'Start initiation of DHT22
WaitMs 2
signal = 1
WaitUs 30
DDRB.2 = 0 'set data pin to input. TrisB.2 = 1 for PIC
ServoIn PORTB.2, b(0) 'Wait for dht22 response
For c = 31 To 0 Step -1 'capture data stream humidity and temp.
ServoIn PORTB.2, b(c)
Next c
'Because of time limit all data is capured without processing.
For c = 31 To 0 Step -1 'process data 0 or 1
If b(c) > 7 Then b(c) = 1 Else b(c) = 0
Next c
For c = 7 To 0 Step -1 'process humidity HB
bi = c + 24
If b(bi) = 1 Then check.c = 1 Else check.c = 0
Next c
humin.HB = check
For c = 7 To 0 Step -1 'process humidity LB
bi = c + 16
If b(bi) = 1 Then check.c = 1 Else check.c = 0
Next c
humin.LB = check
For c = 7 To 0 Step -1 'process temp HB
bi = c + 8
If b(bi) = 1 Then check.c = 1 Else check.c = 0
Next c
tempin.HB = check
For c = 7 To 0 Step -1 'process temp LB
If b(c) = 1 Then check.c = 1 Else check.c = 0
Next c
tempin.LB = check
'Check for minus temperature
If tempin.HB > 127 Then sign = 0x01 Else sign = 0x00
If tempin.HB > 127 Then tempin.HB = tempin.HB - 0x80
'convert data to humidty and temp
tempin = tempin / 10
humin = humin / 10
dew = tempin - ((100 - humin) / 5) 'dewpoint
hsign = sign 'calculate Neg dewpoint + Pos temperature
If humin > 50 And tempin < 15 Then hsign = 0x01
If humin > 60 And tempin < 10 Then hsign = 0x01
If humin > 70 And tempin < 7 Then hsign = 0x01
If humin > 80 And tempin < 4 Then hsign = 0x01
If humin > 90 And tempin < 1 Then hsign = 0x01
If dew = 0 Then hsign = 0x00
t = tempin / 10 'Extract 10's
u = tempin Mod 10 'Extract unit's
th = dew / 10
uh = dew Mod 10
x = t 'convert temperature 10's for gosub look
Gosub look
t = l
If tempin < 10 Then t = 0x00
x = u
Gosub look
u = l
x = th
Gosub look
th = l
If dew < 10 Then th = 0x00
x = uh
Gosub look
uh = l
If th = 0 Then th = 0x00 'if tens = 0 set segment to Blank
If t = 0 Then t = 0x00
SPICSOn 'Start 7 segment LEDs
SPISend 0x09 'set decode mode
SPISend 0x00 'set to None, direct segment control
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000001 'D1
SPISend 0x0d 'c = Centigrade
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000010 'D2
SPISend uh 'hunit
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000011 'D3
SPISend th 'hten or blank
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000100 'D4
SPISend hsign '- or blank
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000101 'D5
SPISend 0x0d 'c = Centigrade
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000110 'D6
SPISend u 'Units
SPICSOff
WaitMs 10
SPICSOn
SPISend %00000111 'D7
SPISend t 'tens or blank
SPICSOff
WaitMs 10
SPICSOn
SPISend %00001000 'D8
SPISend sign '- or blank
SPICSOff
WaitMs 10
Goto loop
End
look: 'convert 10's & units for direct segment control
l = LookUp(0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b), x
Return