commit avent dodo

This commit is contained in:
adri 2018-06-10 03:43:12 +02:00
parent d4d4c3a6a3
commit d0e6eb4795
29 changed files with 5081 additions and 74 deletions

196
1-wire.asm Normal file
View File

@ -0,0 +1,196 @@
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------
.equ OW_PORT = PORTB
.equ OW_PIN = PINB
.equ OW_DDR = DDRB
.equ OW_DQ = PB0
.def OWCount = r17
#define ReadRom 0x33
#define SkipRom 0xcc
#define ConvertTemp 0x44 ; Initiates temperature conversion.
#define WScratch 0x4e ; Writes data into scratchpad bytes 2, 3, and4 (TH, TL, and configuration registers).
#define RScratch 0xbe
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Data segment, variable definitions
;------------------------------------------------------------------------------
.dseg
TempWord: .byte 3
TRegister: .byte 3
ConfigRegister: .byte 2
.cseg
;------------------------------------------------------------------------------
; Output : T - presence bit
;------------------------------------------------------------------------------
OWReset:
cbi OW_PORT,OW_DQ
sbi OW_DDR,OW_DQ
ldi XH, HIGH(DVUS(470))
ldi XL, LOW(DVUS(470))
rcall Wait4xCycles
cbi OW_DDR,OW_DQ
ldi XH, HIGH(DVUS(70))
ldi XL, LOW(DVUS(70))
rcall Wait4xCycles
set
sbis OW_PIN,OW_DQ
clt
ldi XH, HIGH(DVUS(240))
ldi XL, LOW(DVUS(240))
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Input : C - bit to write
;------------------------------------------------------------------------------
OWWriteBit:
brcc OWWriteZero
ldi XH, HIGH(DVUS(1))
ldi XL, LOW(DVUS(1))
rjmp OWWriteOne
OWWriteZero:
ldi XH, HIGH(DVUS(120))
ldi XL, LOW(DVUS(120))
OWWriteOne:
sbi OW_DDR, OW_DQ
rcall Wait4xCycles
cbi OW_DDR, OW_DQ
ldi XH, HIGH(DVUS(60))
ldi XL, LOW(DVUS(60))
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Input : r16 - byte to write
;------------------------------------------------------------------------------
OWWriteByte:
push OWCount
ldi OWCount,0
OWWriteLoop:
ror r16
rcall OWWriteBit
inc OWCount
cpi OWCount,8
brne OWWriteLoop
pop OWCount
ret
;------------------------------------------------------------------------------
; Output : C - bit from slave
;------------------------------------------------------------------------------
OWReadBit:
ldi XH, HIGH(DVUS(1))
ldi XL, LOW(DVUS(1))
sbi OW_DDR, OW_DQ
rcall Wait4xCycles
cbi OW_DDR, OW_DQ
ldi XH, HIGH(DVUS(5))
ldi XL, LOW(DVUS(5))
rcall Wait4xCycles
clt
sbic OW_PIN,OW_DQ
set
ldi XH, HIGH(DVUS(50))
ldi XL, LOW(DVUS(50))
rcall Wait4xCycles
sec
brts OWReadBitEnd
clc
OWReadBitEnd:
ret
;------------------------------------------------------------------------------
; Output : r16 - byte from slave
;------------------------------------------------------------------------------
OWReadByte:
push OWCount
ldi OWCount,0
OWReadLoop:
rcall OWReadBit
ror r16
inc OWCount
cpi OWCount,8
brne OWReadLoop
pop OWCount
ret
;------------------------------------------------------------------------------
; 18b20 MainReadTemp
;------------------------------------------------------------------------------
MainReadTemp:
ldi YL,LOW(TempWord)
ldi YH,HIGH(TempWord)
rcall OWReset ; One wire reset
brts MainReadTemp ; If device not present go to MainLoop
rcall OWReset ; One wire reset
brts MainReadTemp ; If device not present go to MainLoop
rcall OWReset ; One wire reset
brts MainReadTemp ; If device not present go to MainLoop
ldi r16,SkipRom ; Write Skip Rom one wire in "single-drop"
rcall OWWriteByte ;
ldi r16, RScratch ; Write ConvertCommand
rcall OWWriteByte ;
rcall OWReadByte
st Y+, r16 ; Store TEMPERATURE LSB(50h) byte to table, and increment pointer
mov r21, r16
rcall OWReadByte
st Y+, r16 ; Store TEMPERATURE MSB(05h) byte to table, and increment pointer
mov r22, r16
ret
TempRequest:
rcall OWReset ; One wire reset
brts MainReadTemp ; If device not present go to MainLoop
ldi r16,SkipRom ; Write Skip Rom one wire in "single-drop"
rcall OWWriteByte ;
ldi r16, ConvertTemp ; Write ConvertCommand
rcall OWWriteByte ;
ldi r16, 188
rcall WaitMiliseconds
reti
ConvertTempForLCD: ;r18 contiendra la partie décimal et xl la partie entiere
push r16
push r17
ldi YL,LOW(TempWord)
ldi YH,HIGH(TempWord)
ld XL, Y+
ld XH, Y+
lsr XL
lsr XL ;Sup des deux bit inutilisé
ldi r16, 0x03
mov r18, XL
AND r18, r16
ldi r16, 25
mul r18, r16
movw r18, r0
lsr XL
lsr XL ;Sup des deux bit de fraction
ldi r16, 15
and XH,r16
ROR XH
ROR XH
ROR XH
ROR XH
ROR XH ; xh>>4+1(+1 pour le carry)
or XL,XH
pop r17
pop r16
ret

View File

@ -66,9 +66,30 @@
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="1-wire.asm">
<SubType>Code</SubType>
</Compile>
<Compile Include="crc8.asm">
<SubType>Code</SubType>
</Compile>
<Compile Include="div8u.asm">
<SubType>Code</SubType>
</Compile>
<Compile Include="hd44780.asm">
<SubType>Code</SubType>
</Compile>
<Compile Include="hd44780.inc">
<SubType>Code</SubType>
</Compile>
<Compile Include="main.asm"> <Compile Include="main.asm">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="vectors.asm">
<SubType>Code</SubType>
</Compile>
<Compile Include="wait.asm">
<SubType>Code</SubType>
</Compile>
</ItemGroup> </ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Assembler.targets" /> <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Assembler.targets" />
</Project> </Project>

79
Debug/ASM18b20AvecLCD.hex Normal file
View File

@ -0,0 +1,79 @@
:020000020000FC
:0200000070C1CD
:0200040018954D
:02000800189549
:02000C00189545
:02001000189541
:0200140018953D
:02001800189539
:02001C00189535
:02002000189531
:0200240018952D
:02002800189529
:02002C00189525
:02003000189521
:0200340018951D
:02003800189519
:02003C00189515
:02004000189511
:0200440018950D
:02004800189509
:02004C00189505
:02005000189501
:020054001895FD
:020058001895F9
:02005C001895F5
:020060001895F1
:100064001895FF1829E0001F2A9509F40895FF1C2C
:10007400F11A18F4F10E8894F6CF0894F4CF5F9A2D
:1000840000FF5D9800FD5D9A01FF5C9801FD5C9A9C
:1000940002FF5B9802FD5B9A03FF5A9803FD5A9A8C
:1000A4005F9808955E9A0F930295E9DF0F91E7DF59
:1000B400BB27AAEF58D008955E980F930295DFDF0F
:1000C4000F91DDDF02E052D008950591003011F068
:1000D400E9DFFBCF08950A3020F017E3010FE2DFD8
:1000E400089510E3010FDEDF08951F930F93029527
:1000F4000F70F1DF0F910F70EEDF1F910895EE2462
:100104001AE0AFDFE394FF920030D1F710E30F91D0
:10011400010FC8DFEA94D1F708950068CDDF089590
:100124000064CADF0895559A549A539A529A569A7B
:10013400579A5E985F9804E619D013E003E09FDFB6
:1001440005E014D01A95D1F702E099DF01E00ED052
:1001540008E2B2DF08E0B0DF01E0AEDF06E0ACDFCA
:100164000CE0AADF08951197F1F708950F93B7E013
:10017400A0EDF9DFB7E0A0EDF6DF0A95C1F70F9126
:1001840008952898209AB7E0A8E5EDDF2098B1E01B
:10019400A8E1E9DF6894189BE894B3E0A0ECE3DFFE
:1001A400089518F4B0E0A4E002C0B1E0A0EE209AF3
:1001B400DADF2098B0E0A0EFD6DF08951F9310E0B7
:1001C4000795EFDF13951830D9F71F910895B0E024
:1001D400A4E0209AC8DF2098B0E0A4E1C4DFE8944A
:1001E40018996894B0E0A8ECBEDF08940EF08894E7
:1001F40008951F9310E0EBDF079513951830D9F796
:100204001F910895C8E0D1E0BCDFE6F3BADFD6F36E
:10021400B8DFC6F30CECD2DF0EEBD0DFEADF0993D4
:10022400502FE7DF0993602F0895ABDF5EF30CECEA
:10023400C5DF04E4C3DF0CEB99DF18950F931F931C
:10024400C8E0D1E0A991B991A695A69503E02A2F1B
:10025400202309E1209F9001A695A6950FE0B023E5
:10026400B795B795B795B795B795AB2B1F910F91E8
:1002740008950F931F932F930F9318E0209110016B
:10028400022707950091100110F428E10227079531
:10029400009310010F9106950F931A9579F70F911A
:1002A4002F911F910F9108950F9300E00093100177
:1002B4000F91089500911001089569427574746F47
:1002C4006E2052656164657200006176722D6D6303
:1002D400752E6478702E706C00002E0000000FEFF5
:1002E4000DBF21DF01E019DFEEEBF2E0EEDE01E409
:1002F40014DF47DFF6F30CEC61DF0EE45FDF002769
:100304005DDF5CDF0FE35ADF01E407DF3ADFE6F38A
:100314008CDF78DF93DF0C94A4016BDF0030A1F352
:10032400A8DFC0E0D1E0099317E063DFA2DF0993FF
:100334001A95D9F7BFDF003039F700E4EEDEC0E0EC
:10034400D1E012E00F930A2F0F9330EF032320D054
:100354000695069506950695BEDE0F9119D02FE0F9
:100364000223B9DE022F0F9330EF032311D0069539
:10037400069506950695AFDE0F910AD02FE002236D
:10038400AADE0000000000000C948601D9F6BCCF60
:1003940055270A5010F0505FFCCF065F050F0895F3
:00000001FF

1954
Debug/ASM18b20AvecLCD.lss Normal file

File diff suppressed because it is too large Load Diff

772
Debug/ASM18b20AvecLCD.map Normal file
View File

@ -0,0 +1,772 @@
AVRASM ver. 2.2.7 C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm Sun Jun 10 03:42:22 2018
EQU SIGNATURE_000 0000001e
EQU SIGNATURE_001 00000095
EQU SIGNATURE_002 0000000f
EQU UDR0 000000c6
EQU UBRR0L 000000c4
EQU UBRR0H 000000c5
EQU UCSR0C 000000c2
EQU UCSR0B 000000c1
EQU UCSR0A 000000c0
EQU TWAMR 000000bd
EQU TWCR 000000bc
EQU TWDR 000000bb
EQU TWAR 000000ba
EQU TWSR 000000b9
EQU TWBR 000000b8
EQU ASSR 000000b6
EQU OCR2B 000000b4
EQU OCR2A 000000b3
EQU TCNT2 000000b2
EQU TCCR2B 000000b1
EQU TCCR2A 000000b0
EQU OCR1BL 0000008a
EQU OCR1BH 0000008b
EQU OCR1AL 00000088
EQU OCR1AH 00000089
EQU ICR1L 00000086
EQU ICR1H 00000087
EQU TCNT1L 00000084
EQU TCNT1H 00000085
EQU TCCR1C 00000082
EQU TCCR1B 00000081
EQU TCCR1A 00000080
EQU DIDR1 0000007f
EQU DIDR0 0000007e
EQU ADMUX 0000007c
EQU ADCSRB 0000007b
EQU ADCSRA 0000007a
EQU ADCH 00000079
EQU ADCL 00000078
EQU TIMSK2 00000070
EQU TIMSK1 0000006f
EQU TIMSK0 0000006e
EQU PCMSK1 0000006c
EQU PCMSK2 0000006d
EQU PCMSK0 0000006b
EQU EICRA 00000069
EQU PCICR 00000068
EQU OSCCAL 00000066
EQU PRR 00000064
EQU CLKPR 00000061
EQU WDTCSR 00000060
EQU SREG 0000003f
EQU SPL 0000003d
EQU SPH 0000003e
EQU SPMCSR 00000037
EQU MCUCR 00000035
EQU MCUSR 00000034
EQU SMCR 00000033
EQU ACSR 00000030
EQU SPDR 0000002e
EQU SPSR 0000002d
EQU SPCR 0000002c
EQU GPIOR2 0000002b
EQU GPIOR1 0000002a
EQU OCR0B 00000028
EQU OCR0A 00000027
EQU TCNT0 00000026
EQU TCCR0B 00000025
EQU TCCR0A 00000024
EQU GTCCR 00000023
EQU EEARH 00000022
EQU EEARL 00000021
EQU EEDR 00000020
EQU EECR 0000001f
EQU GPIOR0 0000001e
EQU EIMSK 0000001d
EQU EIFR 0000001c
EQU PCIFR 0000001b
EQU TIFR2 00000017
EQU TIFR1 00000016
EQU TIFR0 00000015
EQU PORTD 0000000b
EQU DDRD 0000000a
EQU PIND 00000009
EQU PORTC 00000008
EQU DDRC 00000007
EQU PINC 00000006
EQU PORTB 00000005
EQU DDRB 00000004
EQU PINB 00000003
EQU UDR0_0 00000000
EQU UDR0_1 00000001
EQU UDR0_2 00000002
EQU UDR0_3 00000003
EQU UDR0_4 00000004
EQU UDR0_5 00000005
EQU UDR0_6 00000006
EQU UDR0_7 00000007
EQU MPCM0 00000000
EQU U2X0 00000001
EQU UPE0 00000002
EQU DOR0 00000003
EQU FE0 00000004
EQU UDRE0 00000005
EQU TXC0 00000006
EQU RXC0 00000007
EQU TXB80 00000000
EQU RXB80 00000001
EQU UCSZ02 00000002
EQU TXEN0 00000003
EQU RXEN0 00000004
EQU UDRIE0 00000005
EQU TXCIE0 00000006
EQU RXCIE0 00000007
EQU UCPOL0 00000000
EQU UCSZ00 00000001
EQU UCPHA0 00000001
EQU UCSZ01 00000002
EQU UDORD0 00000002
EQU USBS0 00000003
EQU UPM00 00000004
EQU UPM01 00000005
EQU UMSEL00 00000006
EQU UMSEL0 00000006
EQU UMSEL01 00000007
EQU UMSEL1 00000007
EQU UBRR8 00000000
EQU UBRR9 00000001
EQU UBRR10 00000002
EQU UBRR11 00000003
EQU _UBRR0 00000000
EQU _UBRR1 00000001
EQU UBRR2 00000002
EQU UBRR3 00000003
EQU UBRR4 00000004
EQU UBRR5 00000005
EQU UBRR6 00000006
EQU UBRR7 00000007
EQU TWAM0 00000001
EQU TWAMR0 00000001
EQU TWAM1 00000002
EQU TWAMR1 00000002
EQU TWAM2 00000003
EQU TWAMR2 00000003
EQU TWAM3 00000004
EQU TWAMR3 00000004
EQU TWAM4 00000005
EQU TWAMR4 00000005
EQU TWAM5 00000006
EQU TWAMR5 00000006
EQU TWAM6 00000007
EQU TWAMR6 00000007
EQU TWBR0 00000000
EQU TWBR1 00000001
EQU TWBR2 00000002
EQU TWBR3 00000003
EQU TWBR4 00000004
EQU TWBR5 00000005
EQU TWBR6 00000006
EQU TWBR7 00000007
EQU TWIE 00000000
EQU TWEN 00000002
EQU TWWC 00000003
EQU TWSTO 00000004
EQU TWSTA 00000005
EQU TWEA 00000006
EQU TWINT 00000007
EQU TWPS0 00000000
EQU TWPS1 00000001
EQU TWS3 00000003
EQU TWS4 00000004
EQU TWS5 00000005
EQU TWS6 00000006
EQU TWS7 00000007
EQU TWD0 00000000
EQU TWD1 00000001
EQU TWD2 00000002
EQU TWD3 00000003
EQU TWD4 00000004
EQU TWD5 00000005
EQU TWD6 00000006
EQU TWD7 00000007
EQU TWGCE 00000000
EQU TWA0 00000001
EQU TWA1 00000002
EQU TWA2 00000003
EQU TWA3 00000004
EQU TWA4 00000005
EQU TWA5 00000006
EQU TWA6 00000007
EQU TOIE1 00000000
EQU OCIE1A 00000001
EQU OCIE1B 00000002
EQU ICIE1 00000005
EQU TOV1 00000000
EQU OCF1A 00000001
EQU OCF1B 00000002
EQU ICF1 00000005
EQU WGM10 00000000
EQU WGM11 00000001
EQU COM1B0 00000004
EQU COM1B1 00000005
EQU COM1A0 00000006
EQU COM1A1 00000007
EQU CS10 00000000
EQU CS11 00000001
EQU CS12 00000002
EQU WGM12 00000003
EQU WGM13 00000004
EQU ICES1 00000006
EQU ICNC1 00000007
EQU FOC1B 00000006
EQU FOC1A 00000007
EQU PSRSYNC 00000000
EQU TSM 00000007
EQU TOIE2 00000000
EQU TOIE2A 00000000
EQU OCIE2A 00000001
EQU OCIE2B 00000002
EQU TOV2 00000000
EQU OCF2A 00000001
EQU OCF2B 00000002
EQU WGM20 00000000
EQU WGM21 00000001
EQU COM2B0 00000004
EQU COM2B1 00000005
EQU COM2A0 00000006
EQU COM2A1 00000007
EQU CS20 00000000
EQU CS21 00000001
EQU CS22 00000002
EQU WGM22 00000003
EQU FOC2B 00000006
EQU FOC2A 00000007
EQU TCNT2_0 00000000
EQU TCNT2_1 00000001
EQU TCNT2_2 00000002
EQU TCNT2_3 00000003
EQU TCNT2_4 00000004
EQU TCNT2_5 00000005
EQU TCNT2_6 00000006
EQU TCNT2_7 00000007
EQU OCR2A_0 00000000
EQU OCR2A_1 00000001
EQU OCR2A_2 00000002
EQU OCR2A_3 00000003
EQU OCR2A_4 00000004
EQU OCR2A_5 00000005
EQU OCR2A_6 00000006
EQU OCR2A_7 00000007
EQU OCR2B_0 00000000
EQU OCR2B_1 00000001
EQU OCR2B_2 00000002
EQU OCR2B_3 00000003
EQU OCR2B_4 00000004
EQU OCR2B_5 00000005
EQU OCR2B_6 00000006
EQU OCR2B_7 00000007
EQU TCR2BUB 00000000
EQU TCR2AUB 00000001
EQU OCR2BUB 00000002
EQU OCR2AUB 00000003
EQU TCN2UB 00000004
EQU AS2 00000005
EQU EXCLK 00000006
EQU PSRASY 00000001
EQU PSR2 00000001
EQU MUX0 00000000
EQU MUX1 00000001
EQU MUX2 00000002
EQU MUX3 00000003
EQU ADLAR 00000005
EQU REFS0 00000006
EQU REFS1 00000007
EQU ADPS0 00000000
EQU ADPS1 00000001
EQU ADPS2 00000002
EQU ADIE 00000003
EQU ADIF 00000004
EQU ADATE 00000005
EQU ADSC 00000006
EQU ADEN 00000007
EQU ADTS0 00000000
EQU ADTS1 00000001
EQU ADTS2 00000002
EQU ACME 00000006
EQU ADCH0 00000000
EQU ADCH1 00000001
EQU ADCH2 00000002
EQU ADCH3 00000003
EQU ADCH4 00000004
EQU ADCH5 00000005
EQU ADCH6 00000006
EQU ADCH7 00000007
EQU ADCL0 00000000
EQU ADCL1 00000001
EQU ADCL2 00000002
EQU ADCL3 00000003
EQU ADCL4 00000004
EQU ADCL5 00000005
EQU ADCL6 00000006
EQU ADCL7 00000007
EQU ADC0D 00000000
EQU ADC1D 00000001
EQU ADC2D 00000002
EQU ADC3D 00000003
EQU ADC4D 00000004
EQU ADC5D 00000005
EQU ACIS0 00000000
EQU ACIS1 00000001
EQU ACIC 00000002
EQU ACIE 00000003
EQU ACI 00000004
EQU ACO 00000005
EQU ACBG 00000006
EQU ACD 00000007
EQU AIN0D 00000000
EQU AIN1D 00000001
EQU PORTB0 00000000
EQU PB0 00000000
EQU PORTB1 00000001
EQU PB1 00000001
EQU PORTB2 00000002
EQU PB2 00000002
EQU PORTB3 00000003
EQU PB3 00000003
EQU PORTB4 00000004
EQU PB4 00000004
EQU PORTB5 00000005
EQU PB5 00000005
EQU PORTB6 00000006
EQU PB6 00000006
EQU PORTB7 00000007
EQU PB7 00000007
EQU DDB0 00000000
EQU DDB1 00000001
EQU DDB2 00000002
EQU DDB3 00000003
EQU DDB4 00000004
EQU DDB5 00000005
EQU DDB6 00000006
EQU DDB7 00000007
EQU PINB0 00000000
EQU PINB1 00000001
EQU PINB2 00000002
EQU PINB3 00000003
EQU PINB4 00000004
EQU PINB5 00000005
EQU PINB6 00000006
EQU PINB7 00000007
EQU PORTC0 00000000
EQU PC0 00000000
EQU PORTC1 00000001
EQU PC1 00000001
EQU PORTC2 00000002
EQU PC2 00000002
EQU PORTC3 00000003
EQU PC3 00000003
EQU PORTC4 00000004
EQU PC4 00000004
EQU PORTC5 00000005
EQU PC5 00000005
EQU PORTC6 00000006
EQU PC6 00000006
EQU DDC0 00000000
EQU DDC1 00000001
EQU DDC2 00000002
EQU DDC3 00000003
EQU DDC4 00000004
EQU DDC5 00000005
EQU DDC6 00000006
EQU PINC0 00000000
EQU PINC1 00000001
EQU PINC2 00000002
EQU PINC3 00000003
EQU PINC4 00000004
EQU PINC5 00000005
EQU PINC6 00000006
EQU PORTD0 00000000
EQU PD0 00000000
EQU PORTD1 00000001
EQU PD1 00000001
EQU PORTD2 00000002
EQU PD2 00000002
EQU PORTD3 00000003
EQU PD3 00000003
EQU PORTD4 00000004
EQU PD4 00000004
EQU PORTD5 00000005
EQU PD5 00000005
EQU PORTD6 00000006
EQU PD6 00000006
EQU PORTD7 00000007
EQU PD7 00000007
EQU DDD0 00000000
EQU DDD1 00000001
EQU DDD2 00000002
EQU DDD3 00000003
EQU DDD4 00000004
EQU DDD5 00000005
EQU DDD6 00000006
EQU DDD7 00000007
EQU PIND0 00000000
EQU PIND1 00000001
EQU PIND2 00000002
EQU PIND3 00000003
EQU PIND4 00000004
EQU PIND5 00000005
EQU PIND6 00000006
EQU PIND7 00000007
EQU TOIE0 00000000
EQU OCIE0A 00000001
EQU OCIE0B 00000002
EQU TOV0 00000000
EQU OCF0A 00000001
EQU OCF0B 00000002
EQU WGM00 00000000
EQU WGM01 00000001
EQU COM0B0 00000004
EQU COM0B1 00000005
EQU COM0A0 00000006
EQU COM0A1 00000007
EQU CS00 00000000
EQU CS01 00000001
EQU CS02 00000002
EQU WGM02 00000003
EQU FOC0B 00000006
EQU FOC0A 00000007
EQU TCNT0_0 00000000
EQU TCNT0_1 00000001
EQU TCNT0_2 00000002
EQU TCNT0_3 00000003
EQU TCNT0_4 00000004
EQU TCNT0_5 00000005
EQU TCNT0_6 00000006
EQU TCNT0_7 00000007
EQU OCR0A_0 00000000
EQU OCR0A_1 00000001
EQU OCR0A_2 00000002
EQU OCR0A_3 00000003
EQU OCR0A_4 00000004
EQU OCR0A_5 00000005
EQU OCR0A_6 00000006
EQU OCR0A_7 00000007
EQU OCR0B_0 00000000
EQU OCR0B_1 00000001
EQU OCR0B_2 00000002
EQU OCR0B_3 00000003
EQU OCR0B_4 00000004
EQU OCR0B_5 00000005
EQU OCR0B_6 00000006
EQU OCR0B_7 00000007
EQU PSR10 00000000
EQU ISC00 00000000
EQU ISC01 00000001
EQU ISC10 00000002
EQU ISC11 00000003
EQU INT0 00000000
EQU INT1 00000001
EQU INTF0 00000000
EQU INTF1 00000001
EQU PCIE0 00000000
EQU PCIE1 00000001
EQU PCIE2 00000002
EQU PCINT16 00000000
EQU PCINT17 00000001
EQU PCINT18 00000002
EQU PCINT19 00000003
EQU PCINT20 00000004
EQU PCINT21 00000005
EQU PCINT22 00000006
EQU PCINT23 00000007
EQU PCINT8 00000000
EQU PCINT9 00000001
EQU PCINT10 00000002
EQU PCINT11 00000003
EQU PCINT12 00000004
EQU PCINT13 00000005
EQU PCINT14 00000006
EQU PCINT0 00000000
EQU PCINT1 00000001
EQU PCINT2 00000002
EQU PCINT3 00000003
EQU PCINT4 00000004
EQU PCINT5 00000005
EQU PCINT6 00000006
EQU PCINT7 00000007
EQU PCIF0 00000000
EQU PCIF1 00000001
EQU PCIF2 00000002
EQU SPDR0 00000000
EQU SPDR1 00000001
EQU SPDR2 00000002
EQU SPDR3 00000003
EQU SPDR4 00000004
EQU SPDR5 00000005
EQU SPDR6 00000006
EQU SPDR7 00000007
EQU SPI2X 00000000
EQU WCOL 00000006
EQU SPIF 00000007
EQU SPR0 00000000
EQU SPR1 00000001
EQU CPHA 00000002
EQU CPOL 00000003
EQU MSTR 00000004
EQU DORD 00000005
EQU SPE 00000006
EQU SPIE 00000007
EQU WDP0 00000000
EQU WDP1 00000001
EQU WDP2 00000002
EQU WDE 00000003
EQU WDCE 00000004
EQU WDP3 00000005
EQU WDIE 00000006
EQU WDIF 00000007
EQU SREG_C 00000000
EQU SREG_Z 00000001
EQU SREG_N 00000002
EQU SREG_V 00000003
EQU SREG_S 00000004
EQU SREG_H 00000005
EQU SREG_T 00000006
EQU SREG_I 00000007
EQU CAL0 00000000
EQU CAL1 00000001
EQU CAL2 00000002
EQU CAL3 00000003
EQU CAL4 00000004
EQU CAL5 00000005
EQU CAL6 00000006
EQU CAL7 00000007
EQU CLKPS0 00000000
EQU CLKPS1 00000001
EQU CLKPS2 00000002
EQU CLKPS3 00000003
EQU CLKPCE 00000007
EQU SELFPRGEN 00000000
EQU SPMEN 00000000
EQU PGERS 00000001
EQU PGWRT 00000002
EQU BLBSET 00000003
EQU RWWSRE 00000004
EQU SIGRD 00000005
EQU RWWSB 00000006
EQU SPMIE 00000007
EQU IVCE 00000000
EQU IVSEL 00000001
EQU PUD 00000004
EQU BODSE 00000005
EQU BODS 00000006
EQU PORF 00000000
EQU EXTRF 00000001
EQU EXTREF 00000001
EQU BORF 00000002
EQU WDRF 00000003
EQU SE 00000000
EQU SM0 00000001
EQU SM1 00000002
EQU SM2 00000003
EQU GPIOR20 00000000
EQU GPIOR21 00000001
EQU GPIOR22 00000002
EQU GPIOR23 00000003
EQU GPIOR24 00000004
EQU GPIOR25 00000005
EQU GPIOR26 00000006
EQU GPIOR27 00000007
EQU GPIOR10 00000000
EQU GPIOR11 00000001
EQU GPIOR12 00000002
EQU GPIOR13 00000003
EQU GPIOR14 00000004
EQU GPIOR15 00000005
EQU GPIOR16 00000006
EQU GPIOR17 00000007
EQU GPIOR00 00000000
EQU GPIOR01 00000001
EQU GPIOR02 00000002
EQU GPIOR03 00000003
EQU GPIOR04 00000004
EQU GPIOR05 00000005
EQU GPIOR06 00000006
EQU GPIOR07 00000007
EQU PRADC 00000000
EQU PRUSART0 00000001
EQU PRSPI 00000002
EQU PRTIM1 00000003
EQU PRTIM0 00000005
EQU PRTIM2 00000006
EQU PRTWI 00000007
EQU EEAR0 00000000
EQU EEAR1 00000001
EQU EEAR2 00000002
EQU EEAR3 00000003
EQU EEAR4 00000004
EQU EEAR5 00000005
EQU EEAR6 00000006
EQU EEAR7 00000007
EQU EEAR8 00000000
EQU EEAR9 00000001
EQU EEDR0 00000000
EQU EEDR1 00000001
EQU EEDR2 00000002
EQU EEDR3 00000003
EQU EEDR4 00000004
EQU EEDR5 00000005
EQU EEDR6 00000006
EQU EEDR7 00000007
EQU EERE 00000000
EQU EEPE 00000001
EQU EEMPE 00000002
EQU EERIE 00000003
EQU EEPM0 00000004
EQU EEPM1 00000005
EQU LB1 00000000
EQU LB2 00000001
EQU BLB01 00000002
EQU BLB02 00000003
EQU BLB11 00000004
EQU BLB12 00000005
EQU CKSEL0 00000000
EQU CKSEL1 00000001
EQU CKSEL2 00000002
EQU CKSEL3 00000003
EQU SUT0 00000004
EQU SUT1 00000005
EQU CKOUT 00000006
EQU CKDIV8 00000007
EQU BOOTRST 00000000
EQU BOOTSZ0 00000001
EQU BOOTSZ1 00000002
EQU EESAVE 00000003
EQU WDTON 00000004
EQU SPIEN 00000005
EQU DWEN 00000006
EQU RSTDISBL 00000007
EQU BODLEVEL0 00000000
EQU BODLEVEL1 00000001
EQU BODLEVEL2 00000002
DEF XH r27
DEF XL r26
DEF YH r29
DEF YL r28
DEF ZH r31
DEF ZL r30
EQU FLASHEND 00003fff
EQU IOEND 000000ff
EQU SRAM_START 00000100
EQU SRAM_SIZE 00000800
EQU RAMEND 000008ff
EQU XRAMEND 00000000
EQU E2END 000003ff
EQU EEPROMEND 000003ff
EQU EEADRBITS 0000000a
EQU NRWW_START_ADDR 00003800
EQU NRWW_STOP_ADDR 00003fff
EQU RWW_START_ADDR 00000000
EQU RWW_STOP_ADDR 000037ff
EQU PAGESIZE 00000040
EQU FIRSTBOOTSTART 00003f00
EQU SECONDBOOTSTART 00003e00
EQU THIRDBOOTSTART 00003c00
EQU FOURTHBOOTSTART 00003800
EQU SMALLBOOTSTART 00003f00
EQU LARGEBOOTSTART 00003800
EQU INT0addr 00000002
EQU INT1addr 00000004
EQU PCI0addr 00000006
EQU PCI1addr 00000008
EQU PCI2addr 0000000a
EQU WDTaddr 0000000c
EQU OC2Aaddr 0000000e
EQU OC2Baddr 00000010
EQU OVF2addr 00000012
EQU ICP1addr 00000014
EQU OC1Aaddr 00000016
EQU OC1Baddr 00000018
EQU OVF1addr 0000001a
EQU OC0Aaddr 0000001c
EQU OC0Baddr 0000001e
EQU OVF0addr 00000020
EQU SPIaddr 00000022
EQU URXCaddr 00000024
EQU UDREaddr 00000026
EQU UTXCaddr 00000028
EQU ADCCaddr 0000002a
EQU ERDYaddr 0000002c
EQU ACIaddr 0000002e
EQU TWIaddr 00000030
EQU SPMRaddr 00000032
EQU INT_VECTORS_SIZE 00000034
DSEG SerialNumber 00000100
CSEG ProgramEntryPoint 00000171
EQU LCD_PORT 0000000b
EQU LCD_DDR 0000000a
EQU LCD_PIN 00000009
EQU LCD_D4 00000005
EQU LCD_D5 00000004
EQU LCD_D6 00000003
EQU LCD_D7 00000002
EQU LCD_RS 00000006
EQU LCD_EN 00000007
DEF drem8u r15
DEF dres8u r16
DEF dd8u r16
DEF dv8u r17
DEF dcnt8u r18
CSEG div8u 00000033
CSEG d8u_1 00000035
CSEG d8u_2 00000039
CSEG d8u_3 0000003f
CSEG LCD_WriteNibble 00000041
CSEG LCD_WriteData 00000054
CSEG Wait4xCycles 000000b5
CSEG LCD_WriteCommand 0000005e
CSEG WaitMiliseconds 000000b8
CSEG LCD_WriteString 00000067
CSEG exit 0000006c
CSEG LCD_WriteHexDigit 0000006d
CSEG Num 00000073
CSEG LCD_WriteHex8 00000077
CSEG LCD_WriteDecimal 00000081
CSEG LCD_WriteDecimalLoop 00000082
CSEG LCD_WriteDecimalLoop2 00000088
CSEG LCD_SetAddressDD 0000008f
CSEG LCD_SetAddressCG 00000092
CSEG LCD_Init 00000095
CSEG InitLoop 000000a0
CSEG WaitMsLoop 000000b9
EQU OW_PORT 00000005
EQU OW_PIN 00000003
EQU OW_DDR 00000004
EQU OW_DQ 00000000
DEF OWCount r17
DSEG TempWord 00000108
DSEG TRegister 0000010b
DSEG ConfigRegister 0000010e
CSEG OWReset 000000c3
CSEG OWWriteBit 000000d3
CSEG OWWriteZero 000000d7
CSEG OWWriteOne 000000d9
CSEG OWWriteByte 000000e0
CSEG OWWriteLoop 000000e2
CSEG OWReadBit 000000e9
CSEG OWReadBitEnd 000000fa
CSEG OWReadByte 000000fb
CSEG OWReadLoop 000000fd
CSEG MainReadTemp 00000104
CSEG TempRequest 00000117
CSEG ConvertTempForLCD 00000120
DSEG _crc 00000110
CSEG CRC8Update 0000013b
CSEG CRC8L 00000140
CSEG CRC8zero 00000149
CSEG CRC8Init 00000156
CSEG GetCRC8 0000015c
CSEG Text1 0000015f
CSEG Text2 00000167
CSEG Tp 0000016f
CSEG ConfigResolTo10Bits 0000017b
CSEG MainLoop 00000186
CSEG LoadLoop 000001a4
CSEG StoreLoop 00000197
CSEG bin2bcd8 000001ca
CSEG bBCD8_1 000001cb
CSEG bBCD8_2 000001cf

BIN
Debug/ASM18b20AvecLCD.obj Normal file

Binary file not shown.

89
Debug/ASM18b20AvecLCD.tmp Normal file
View File

@ -0,0 +1,89 @@
<ASSEMBLER_INFO>
<VERSION>2.2.7</VERSION>
<DEVICE>"ATmega328P"</DEVICE>
<WORKING_DIR>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\Debug</WORKING_DIR>
<INCLUDE_PATH>
<DIR>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\avrasm\inc</DIR>
<DIR>C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avrassembler\Include</DIR>
<DIR></DIR>
</INCLUDE_PATH>
<SOURCE_FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</SOURCE_FILE>
<INCLUDED_FILES>
<FILE>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.150\avrasm\inc\m328pdef.inc</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\vectors.asm</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.inc</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE>
</INCLUDED_FILES>
<OBJECT_FILES>
<FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\Debug\ASM18b20AvecLCD.obj</FILE>
</OBJECT_FILES>
<HEX_FILES>
<FILE>ASM18b20AvecLCD.hex</FILE>
</HEX_FILES>
<OUTPUT_FILES>
<FILE>ASM18b20AvecLCD.map</FILE>
<FILE>ASM18b20AvecLCD.lss</FILE>
</OUTPUT_FILES>
<LABELS>
<SerialNumber><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>25</LINE></SerialNumber>
<ProgramEntryPoint><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>51</LINE></ProgramEntryPoint>
<div8u><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm</FILE><LINE>12</LINE></div8u>
<d8u_1><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm</FILE><LINE>15</LINE></d8u_1>
<d8u_2><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm</FILE><LINE>20</LINE></d8u_2>
<d8u_3><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\div8u.asm</FILE><LINE>27</LINE></d8u_3>
<LCD_WriteNibble><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>33</LINE></LCD_WriteNibble>
<LCD_WriteData><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>61</LINE></LCD_WriteData>
<Wait4xCycles><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm</FILE><LINE>24</LINE></Wait4xCycles>
<LCD_WriteCommand><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>76</LINE></LCD_WriteCommand>
<WaitMiliseconds><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm</FILE><LINE>32</LINE></WaitMiliseconds>
<LCD_WriteString><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>89</LINE></LCD_WriteString>
<exit><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>95</LINE></exit>
<LCD_WriteHexDigit><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>100</LINE></LCD_WriteHexDigit>
<Num><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>107</LINE></Num>
<LCD_WriteHex8><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>115</LINE></LCD_WriteHex8>
<LCD_WriteDecimal><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>130</LINE></LCD_WriteDecimal>
<LCD_WriteDecimalLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>132</LINE></LCD_WriteDecimalLoop>
<LCD_WriteDecimalLoop2><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>140</LINE></LCD_WriteDecimalLoop2>
<LCD_SetAddressDD><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>151</LINE></LCD_SetAddressDD>
<LCD_SetAddressCG><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>158</LINE></LCD_SetAddressCG>
<LCD_Init><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>165</LINE></LCD_Init>
<InitLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\hd44780.asm</FILE><LINE>181</LINE></InitLoop>
<WaitMsLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\wait.asm</FILE><LINE>34</LINE></WaitMsLoop>
<TempWord><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>26</LINE></TempWord>
<TRegister><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>27</LINE></TRegister>
<ConfigRegister><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>28</LINE></ConfigRegister>
<OWReset><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>37</LINE></OWReset>
<OWWriteBit><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>63</LINE></OWWriteBit>
<OWWriteZero><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>68</LINE></OWWriteZero>
<OWWriteOne><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>71</LINE></OWWriteOne>
<OWWriteByte><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>83</LINE></OWWriteByte>
<OWWriteLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>86</LINE></OWWriteLoop>
<OWReadBit><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>97</LINE></OWReadBit>
<OWReadBitEnd><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>115</LINE></OWReadBitEnd>
<OWReadByte><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>120</LINE></OWReadByte>
<OWReadLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>123</LINE></OWReadLoop>
<MainReadTemp><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>134</LINE></MainReadTemp>
<TempRequest><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>156</LINE></TempRequest>
<ConvertTempForLCD><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\1-wire.asm</FILE><LINE>168</LINE></ConvertTempForLCD>
<_crc><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>13</LINE></_crc>
<CRC8Update><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>21</LINE></CRC8Update>
<CRC8L><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>28</LINE></CRC8L>
<CRC8zero><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>37</LINE></CRC8zero>
<CRC8Init><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>53</LINE></CRC8Init>
<GetCRC8><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\crc8.asm</FILE><LINE>62</LINE></GetCRC8>
<Text1><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>42</LINE></Text1>
<Text2><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>44</LINE></Text2>
<Tp><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>46</LINE></Tp>
<ConfigResolTo10Bits><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>70</LINE></ConfigResolTo10Bits>
<MainLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>85</LINE></MainLoop>
<LoadLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>126</LINE></LoadLoop>
<StoreLoop><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>109</LINE></StoreLoop>
<bin2bcd8><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>188</LINE></bin2bcd8>
<bBCD8_1><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>190</LINE></bBCD8_1>
<bBCD8_2><FILE>C:\Users\adrie\Nextcloud\iset\2IS\2IS\ASM JR\ASM18b20AvecLCD\ASM18b20AvecLCD\ASM18b20AvecLCD\main.asm</FILE><LINE>195</LINE></bBCD8_2>
</LABELS>
</ASSEMBLER_INFO>

67
crc8.asm Normal file
View File

@ -0,0 +1,67 @@
;------------------------------------------------------------------------------
; CRC8 computing functions
; based on Application Note 27 from Dallas Semiconductor
; http://avr-mcu.dxp.pl
; e-mail: radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Data segment
;------------------------------------------------------------------------------
.dseg
_crc : .byte 1
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg
;------------------------------------------------------------------------------
; Update crc value
;------------------------------------------------------------------------------
CRC8Update:
push r16
push r17
push r18
push r16
ldi r17, 8
CRC8L:
lds r18, _crc
eor r16, r18
ror r16
lds r16, _crc
brcc CRC8zero
ldi r18, 0x18
eor r16, r18
CRC8zero:
ror r16
sts _crc, r16
pop r16
lsr r16
push r16
dec r17
brne CRC8L
pop r16
pop r18
pop r17
pop r16
ret
;------------------------------------------------------------------------------
; Clear crc value
;------------------------------------------------------------------------------
CRC8Init:
push r16
ldi r16,0
sts _crc, r16
pop r16
ret
;------------------------------------------------------------------------------
; Copy crc value to r16
;------------------------------------------------------------------------------
GetCRC8:
lds r16, _crc
ret
;------------------------------------------------------------------------------
; End of crc8.asm file
;------------------------------------------------------------------------------

29
div8u.asm Normal file
View File

@ -0,0 +1,29 @@
.cseg
;***** Subroutine Register Variables
.def drem8u =r15 ;remainder
.def dres8u =r16 ;result
.def dd8u =r16 ;dividend
.def dv8u =r17 ;divisor
.def dcnt8u =r18 ;loop counter
;***** Code
div8u:
sub drem8u,drem8u ; clear remainder and carry
ldi dcnt8u,9 ; init loop counter
d8u_1:
rol dd8u ; shift left dividend
dec dcnt8u ; decrement counter
brne d8u_2 ; if done
ret ; return
d8u_2:
rol drem8u ; shift dividend into remainder
sub drem8u,dv8u ; remainder = remainder - divisor
brcc d8u_3 ; if result negative
add drem8u,dv8u ; restore remainder
clc ; clear carry to be shifted into result
rjmp d8u_1 ; else
d8u_3:
sec ; set carry to be shifted into result
rjmp d8u_1

215
hd44780.asm Normal file
View File

@ -0,0 +1,215 @@
;------------------------------------------------------------------------------
; HD44780 LCD Assembly driver
; http://avr-mcu.dxp.pl
; e-mail : radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
.include "hd44780.inc"
.equ LCD_PORT = PORTD
.equ LCD_DDR = DDRD
.equ LCD_PIN = PIND
.equ LCD_D4 = 5
.equ LCD_D5 = 4
.equ LCD_D6 = 3
.equ LCD_D7 = 2
.equ LCD_RS = 6
.equ LCD_EN = 7
;------------------------------------------------------------------------------
; Data segment
;------------------------------------------------------------------------------
.dseg
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg
#include "div8u.asm"
;------------------------------------------------------------------------------
; Write half byte to LCD
;------------------------------------------------------------------------------
LCD_WriteNibble:
sbi LCD_PORT, LCD_EN
sbrs r16, 0
cbi LCD_PORT, LCD_D4
sbrc r16, 0
sbi LCD_PORT, LCD_D4
sbrs r16, 1
cbi LCD_PORT, LCD_D5
sbrc r16, 1
sbi LCD_PORT, LCD_D5
sbrs r16, 2
cbi LCD_PORT, LCD_D6
sbrc r16, 2
sbi LCD_PORT, LCD_D6
sbrs r16, 3
cbi LCD_PORT, LCD_D7
sbrc r16, 3
sbi LCD_PORT, LCD_D7
cbi LCD_PORT, LCD_EN
ret
;------------------------------------------------------------------------------
; Write data byte to LCD
;------------------------------------------------------------------------------
LCD_WriteData:
sbi LCD_PORT, LCD_RS
push r16
swap r16
rcall LCD_WriteNibble
pop r16
rcall LCD_WriteNibble
clr XH
ldi XL,250
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Write command byte to LCD
;------------------------------------------------------------------------------
LCD_WriteCommand:
cbi LCD_PORT, LCD_RS
push r16
swap r16
rcall LCD_WriteNibble
pop r16
rcall LCD_WriteNibble
ldi r16,2
rcall WaitMiliseconds
ret
;------------------------------------------------------------------------------
; Write string (from program memory)
;------------------------------------------------------------------------------
LCD_WriteString:
lpm r16, Z+
cpi r16, 0
breq exit
rcall LCD_WriteData
rjmp LCD_WriteString
exit:
ret
;------------------------------------------------------------------------------
; Display one digit in HEX code
;------------------------------------------------------------------------------
LCD_WriteHexDigit:
cpi r16,10
brlo Num
ldi r17,'7'
add r16,r17
rcall LCD_WriteData
ret
Num:
ldi r17,'0'
add r16,r17
rcall LCD_WriteData
ret
;------------------------------------------------------------------------------
; Display 8-byte hex value of r16
;------------------------------------------------------------------------------
LCD_WriteHex8:
push r17
push r16
swap r16
andi r16,0x0F
rcall LCD_WriteHexDigit
pop r16
andi r16,0x0F
rcall LCD_WriteHexDigit
pop r17
ret
;------------------------------------------------------------------------------
; Display decimal value of r16
;------------------------------------------------------------------------------
LCD_WriteDecimal:
clr r14
LCD_WriteDecimalLoop:
ldi r17,10
rcall div8u
inc r14
push r15
cpi r16,0
brne LCD_WriteDecimalLoop
LCD_WriteDecimalLoop2:
ldi r17,'0'
pop r16
add r16,r17
rcall LCD_WriteData
dec r14
brne LCD_WriteDecimalLoop2
ret
;------------------------------------------------------------------------------
; Set address in Display Data RAM
;------------------------------------------------------------------------------
LCD_SetAddressDD:
ori r16, HD44780_DDRAM_SET
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; Set address in Character Generator RAM
;------------------------------------------------------------------------------
LCD_SetAddressCG:
ori r16, HD44780_CGRAM_SET
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; Initialization of LCD
;------------------------------------------------------------------------------
LCD_Init:
sbi LCD_DDR, LCD_D4
sbi LCD_DDR, LCD_D5
sbi LCD_DDR, LCD_D6
sbi LCD_DDR, LCD_D7
sbi LCD_DDR, LCD_RS
sbi LCD_DDR, LCD_EN
cbi LCD_PORT, LCD_RS
cbi LCD_PORT, LCD_EN
ldi r16, 100
rcall WaitMiliseconds
ldi r17, 3
InitLoop:
ldi r16, 0x03
rcall LCD_WriteNibble
ldi r16, 5
rcall WaitMiliseconds
dec r17
brne InitLoop
ldi r16, 0x02
rcall LCD_WriteNibble
ldi r16, 1
rcall WaitMiliseconds
ldi r16, HD44780_FUNCTION_SET | HD44780_FONT5x7 | HD44780_TWO_LINE | HD44780_4_BIT
rcall LCD_WriteCommand
ldi r16, HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_OFF
rcall LCD_WriteCommand
ldi r16, HD44780_CLEAR
rcall LCD_WriteCommand
ldi r16, HD44780_ENTRY_MODE |HD44780_EM_SHIFT_CURSOR | HD44780_EM_INCREMENT
rcall LCD_WriteCommand
ldi r16, HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_ON | HD44780_CURSOR_OFF | HD44780_CURSOR_NOBLINK
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; End of file
;------------------------------------------------------------------------------

38
hd44780.inc Normal file
View File

@ -0,0 +1,38 @@
#define HD44780_CLEAR 0x01
#define HD44780_HOME 0x02
#define HD44780_ENTRY_MODE 0x04
#define HD44780_EM_SHIFT_CURSOR 0
#define HD44780_EM_SHIFT_DISPLAY 1
#define HD44780_EM_DECREMENT 0
#define HD44780_EM_INCREMENT 2
#define HD44780_DISPLAY_ONOFF 0x08
#define HD44780_DISPLAY_OFF 0
#define HD44780_DISPLAY_ON 4
#define HD44780_CURSOR_OFF 0
#define HD44780_CURSOR_ON 2
#define HD44780_CURSOR_NOBLINK 0
#define HD44780_CURSOR_BLINK 1
#define HD44780_DISPLAY_CURSOR_SHIFT 0x10
#define HD44780_SHIFT_CURSOR 0
#define HD44780_SHIFT_DISPLAY 8
#define HD44780_SHIFT_LEFT 0
#define HD44780_SHIFT_RIGHT 4
#define HD44780_FUNCTION_SET 0x20
#define HD44780_FONT5x7 0
#define HD44780_FONT5x10 4
#define HD44780_ONE_LINE 0
#define HD44780_TWO_LINE 8
#define HD44780_4_BIT 0
#define HD44780_8_BIT 16
#define HD44780_CGRAM_SET 0x40
#define HD44780_DDRAM_SET 0x80
#define HD44780_LINE0 0x00
#define HD44780_LINE1 0x40

View File

@ -0,0 +1,113 @@
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------
.equ OW_PORT = PORTD
.equ OW_PIN = PIND
.equ OW_DDR = DDRD
.equ OW_DQ = PD6
.def OWCount = r17
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------
.cseg
;------------------------------------------------------------------------------
; Output : T - presence bit
;------------------------------------------------------------------------------
OWReset:
cbi OW_PORT,OW_DQ
sbi OW_DDR,OW_DQ
ldi XH, HIGH(DVUS(470))
ldi XL, LOW(DVUS(470))
rcall Wait4xCycles
cbi OW_DDR,OW_DQ
ldi XH, HIGH(DVUS(70))
ldi XL, LOW(DVUS(70))
rcall Wait4xCycles
set
sbis OW_PIN,OW_DQ
clt
ldi XH, HIGH(DVUS(240))
ldi XL, LOW(DVUS(240))
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Input : C - bit to write
;------------------------------------------------------------------------------
OWWriteBit:
brcc OWWriteZero
ldi XH, HIGH(DVUS(1))
ldi XL, LOW(DVUS(1))
rjmp OWWriteOne
OWWriteZero:
ldi XH, HIGH(DVUS(120))
ldi XL, LOW(DVUS(120))
OWWriteOne:
sbi OW_DDR, OW_DQ
rcall Wait4xCycles
cbi OW_DDR, OW_DQ
ldi XH, HIGH(DVUS(60))
ldi XL, LOW(DVUS(60))
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Input : r16 - byte to write
;------------------------------------------------------------------------------
OWWriteByte:
push OWCount
ldi OWCount,0
OWWriteLoop:
ror r16
rcall OWWriteBit
inc OWCount
cpi OWCount,8
brne OWWriteLoop
pop OWCount
ret
;------------------------------------------------------------------------------
; Output : C - bit from slave
;------------------------------------------------------------------------------
OWReadBit:
ldi XH, HIGH(DVUS(1))
ldi XL, LOW(DVUS(1))
sbi OW_DDR, OW_DQ
rcall Wait4xCycles
cbi OW_DDR, OW_DQ
ldi XH, HIGH(DVUS(5))
ldi XL, LOW(DVUS(5))
rcall Wait4xCycles
clt
sbic OW_PIN,OW_DQ
set
ldi XH, HIGH(DVUS(50))
ldi XL, LOW(DVUS(50))
rcall Wait4xCycles
sec
brts OWReadBitEnd
clc
OWReadBitEnd:
ret
;------------------------------------------------------------------------------
; Output : r16 - byte from slave
;------------------------------------------------------------------------------
OWReadByte:
push OWCount
ldi OWCount,0
OWReadLoop:
rcall OWReadBit
ror r16
inc OWCount
cpi OWCount,8
brne OWReadLoop
pop OWCount
ret
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------

View File

@ -0,0 +1,2 @@
@ECHO OFF
"C:\Program Files (x86)\Atmel\AVR Tools\AvrAssembler2\avrasm2.exe" -S "F:\WORK\uK\AVR\Projects\ibutton-number-read\labels.tmp" -fI -W+ie -o "F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.hex" -d "F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.obj" -e "F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.eep" -m "F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.map" "F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm"

View File

@ -0,0 +1,67 @@
;------------------------------------------------------------------------------
; CRC8 computing functions
; based on Application Note 27 from Dallas Semiconductor
; http://avr-mcu.dxp.pl
; e-mail: radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Data segment
;------------------------------------------------------------------------------
.dseg
_crc : .byte 1
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg
;------------------------------------------------------------------------------
; Update crc value
;------------------------------------------------------------------------------
CRC8Update:
push r16
push r17
push r18
push r16
ldi r17, 8
CRC8L:
lds r18, _crc
eor r16, r18
ror r16
lds r16, _crc
brcc CRC8zero
ldi r18, 0x18
eor r16, r18
CRC8zero:
ror r16
sts _crc, r16
pop r16
lsr r16
push r16
dec r17
brne CRC8L
pop r16
pop r18
pop r17
pop r16
ret
;------------------------------------------------------------------------------
; Clear crc value
;------------------------------------------------------------------------------
CRC8Init:
push r16
ldi r16,0
sts _crc, r16
pop r16
ret
;------------------------------------------------------------------------------
; Copy crc value to r16
;------------------------------------------------------------------------------
GetCRC8:
lds r16, _crc
ret
;------------------------------------------------------------------------------
; End of crc8.asm file
;------------------------------------------------------------------------------

View File

@ -0,0 +1,29 @@
.cseg
;***** Subroutine Register Variables
.def drem8u =r15 ;remainder
.def dres8u =r16 ;result
.def dd8u =r16 ;dividend
.def dv8u =r17 ;divisor
.def dcnt8u =r18 ;loop counter
;***** Code
div8u:
sub drem8u,drem8u ; clear remainder and carry
ldi dcnt8u,9 ; init loop counter
d8u_1:
rol dd8u ; shift left dividend
dec dcnt8u ; decrement counter
brne d8u_2 ; if done
ret ; return
d8u_2:
rol drem8u ; shift dividend into remainder
sub drem8u,dv8u ; remainder = remainder - divisor
brcc d8u_3 ; if result negative
add drem8u,dv8u ; restore remainder
clc ; clear carry to be shifted into result
rjmp d8u_1 ; else
d8u_3:
sec ; set carry to be shifted into result
rjmp d8u_1

View File

@ -0,0 +1,216 @@
;------------------------------------------------------------------------------
; HD44780 LCD Assembly driver
; http://avr-mcu.dxp.pl
; e-mail : radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
.include "tn2313def.inc"
.include "hd44780.inc"
.equ LCD_PORT = PORTB
.equ LCD_DDR = DDRB
.equ LCD_PIN = PINB
.equ LCD_D4 = 0
.equ LCD_D5 = 1
.equ LCD_D6 = 2
.equ LCD_D7 = 3
.equ LCD_RS = 4
.equ LCD_EN = 6
;------------------------------------------------------------------------------
; Data segment
;------------------------------------------------------------------------------
.dseg
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg
#include "div8u.asm"
;------------------------------------------------------------------------------
; Write half byte to LCD
;------------------------------------------------------------------------------
LCD_WriteNibble:
sbi LCD_PORT, LCD_EN
sbrs r16, 0
cbi LCD_PORT, LCD_D4
sbrc r16, 0
sbi LCD_PORT, LCD_D4
sbrs r16, 1
cbi LCD_PORT, LCD_D5
sbrc r16, 1
sbi LCD_PORT, LCD_D5
sbrs r16, 2
cbi LCD_PORT, LCD_D6
sbrc r16, 2
sbi LCD_PORT, LCD_D6
sbrs r16, 3
cbi LCD_PORT, LCD_D7
sbrc r16, 3
sbi LCD_PORT, LCD_D7
cbi LCD_PORT, LCD_EN
ret
;------------------------------------------------------------------------------
; Write data byte to LCD
;------------------------------------------------------------------------------
LCD_WriteData:
sbi LCD_PORT, LCD_RS
push r16
swap r16
rcall LCD_WriteNibble
pop r16
rcall LCD_WriteNibble
clr XH
ldi XL,250
rcall Wait4xCycles
ret
;------------------------------------------------------------------------------
; Write command byte to LCD
;------------------------------------------------------------------------------
LCD_WriteCommand:
cbi LCD_PORT, LCD_RS
push r16
swap r16
rcall LCD_WriteNibble
pop r16
rcall LCD_WriteNibble
ldi r16,2
rcall WaitMiliseconds
ret
;------------------------------------------------------------------------------
; Write string (from program memory)
;------------------------------------------------------------------------------
LCD_WriteString:
lpm r16, Z+
cpi r16, 0
breq exit
rcall LCD_WriteData
rjmp LCD_WriteString
exit:
ret
;------------------------------------------------------------------------------
; Display one digit in HEX code
;------------------------------------------------------------------------------
LCD_WriteHexDigit:
cpi r16,10
brlo Num
ldi r17,'7'
add r16,r17
rcall LCD_WriteData
ret
Num:
ldi r17,'0'
add r16,r17
rcall LCD_WriteData
ret
;------------------------------------------------------------------------------
; Display 8-byte hex value of r16
;------------------------------------------------------------------------------
LCD_WriteHex8:
push r17
push r16
swap r16
andi r16,0x0F
rcall LCD_WriteHexDigit
pop r16
andi r16,0x0F
rcall LCD_WriteHexDigit
pop r17
ret
;------------------------------------------------------------------------------
; Display decimal value of r16
;------------------------------------------------------------------------------
LCD_WriteDecimal:
clr r14
LCD_WriteDecimalLoop:
ldi r17,10
rcall div8u
inc r14
push r15
cpi r16,0
brne LCD_WriteDecimalLoop
LCD_WriteDecimalLoop2:
ldi r17,'0'
pop r16
add r16,r17
rcall LCD_WriteData
dec r14
brne LCD_WriteDecimalLoop2
ret
;------------------------------------------------------------------------------
; Set address in Display Data RAM
;------------------------------------------------------------------------------
LCD_SetAddressDD:
ori r16, HD44780_DDRAM_SET
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; Set address in Character Generator RAM
;------------------------------------------------------------------------------
LCD_SetAddressCG:
ori r16, HD44780_CGRAM_SET
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; Initialization of LCD
;------------------------------------------------------------------------------
LCD_Init:
sbi LCD_DDR, LCD_D4
sbi LCD_DDR, LCD_D5
sbi LCD_DDR, LCD_D6
sbi LCD_DDR, LCD_D7
sbi LCD_DDR, LCD_RS
sbi LCD_DDR, LCD_EN
cbi LCD_PORT, LCD_RS
cbi LCD_PORT, LCD_EN
ldi r16, 100
rcall WaitMiliseconds
ldi r17, 3
InitLoop:
ldi r16, 0x03
rcall LCD_WriteNibble
ldi r16, 5
rcall WaitMiliseconds
dec r17
brne InitLoop
ldi r16, 0x02
rcall LCD_WriteNibble
ldi r16, 1
rcall WaitMiliseconds
ldi r16, HD44780_FUNCTION_SET | HD44780_FONT5x7 | HD44780_TWO_LINE | HD44780_4_BIT
rcall LCD_WriteCommand
ldi r16, HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_OFF
rcall LCD_WriteCommand
ldi r16, HD44780_CLEAR
rcall LCD_WriteCommand
ldi r16, HD44780_ENTRY_MODE |HD44780_EM_SHIFT_CURSOR | HD44780_EM_INCREMENT
rcall LCD_WriteCommand
ldi r16, HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_ON | HD44780_CURSOR_OFF | HD44780_CURSOR_NOBLINK
rcall LCD_WriteCommand
ret
;------------------------------------------------------------------------------
; End of file
;------------------------------------------------------------------------------

View File

@ -0,0 +1,38 @@
#define HD44780_CLEAR 0x01
#define HD44780_HOME 0x02
#define HD44780_ENTRY_MODE 0x04
#define HD44780_EM_SHIFT_CURSOR 0
#define HD44780_EM_SHIFT_DISPLAY 1
#define HD44780_EM_DECREMENT 0
#define HD44780_EM_INCREMENT 2
#define HD44780_DISPLAY_ONOFF 0x08
#define HD44780_DISPLAY_OFF 0
#define HD44780_DISPLAY_ON 4
#define HD44780_CURSOR_OFF 0
#define HD44780_CURSOR_ON 2
#define HD44780_CURSOR_NOBLINK 0
#define HD44780_CURSOR_BLINK 1
#define HD44780_DISPLAY_CURSOR_SHIFT 0x10
#define HD44780_SHIFT_CURSOR 0
#define HD44780_SHIFT_DISPLAY 8
#define HD44780_SHIFT_LEFT 0
#define HD44780_SHIFT_RIGHT 4
#define HD44780_FUNCTION_SET 0x20
#define HD44780_FONT5x7 0
#define HD44780_FONT5x10 4
#define HD44780_ONE_LINE 0
#define HD44780_TWO_LINE 8
#define HD44780_4_BIT 0
#define HD44780_8_BIT 16
#define HD44780_CGRAM_SET 0x40
#define HD44780_DDRAM_SET 0x80
#define HD44780_LINE0 0x00
#define HD44780_LINE1 0x40

View File

@ -0,0 +1 @@
<AVRStudio><MANAGEMENT><ProjectName>ibutton-number-read</ProjectName><Created>04-Dec-2011 17:57:47</Created><LastEdit>06-Dec-2011 17:56:07</LastEdit><ICON>208</ICON><ProjectType>0</ProjectType><Created>04-Dec-2011 17:57:47</Created><Version>4</Version><Build>4, 15, 0, 623</Build><ProjectTypeName>Atmel AVR Assembler</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>ibutton-number-read.obj</ObjectFile><EntryFile>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</EntryFile><SaveFolder>F:\WORK\uK\AVR\Projects\ibutton-number-read\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATtiny2313.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AvrAssembler><Folder>F:\WORK\uK\AVR\Projects\ibutton-number-read\</Folder><RelPath>main.asm</RelPath><EntryFile>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</EntryFile><IncludePath>C:\Program Files (x86)\Atmel\AVR Tools\AvrAssembler\Appnotes</IncludePath><V2IncludePath></V2IncludePath><V2Parameters></V2Parameters><FileType>I</FileType><ObjectName>ibutton-number-read</ObjectName><Wrap>0</Wrap><ErrorAsWarning>0</ErrorAsWarning><MapFile>1</MapFile><ListFile>0</ListFile><Version1>0</Version1><PreCompile></PreCompile><PostCompile></PostCompile><SourceFiles>,</SourceFiles></AvrAssembler><ProjectIncludeDirs><Dirs><Dir>C:\Program Files (x86)\Atmel\AVR Tools\AvrAssembler2\Appnotes</Dir></Dirs></ProjectIncludeDirs><ProjectFiles><Files><Name>\main.asm</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.asm</FileName><Status>1</Status></File00000><File00001><FileId>00001</FileId><FileName>hd44780.inc</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>crc8.asm</FileName><Status>1</Status></File00002></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>

View File

@ -0,0 +1 @@
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATTINY2313"/><Files><File00000 Name="F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm" Position="-31738 -31948 -30432 -31215" LineCol="144 20" State="Maximized"/><File00001 Name="F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.inc" Position="-31646 -31837 -30568 -31351" LineCol="37 8" State="Maximized"/><File00002 Name="F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm" Position="-31580 -31771 -30502 -31285" LineCol="39 9" State="Maximized"/></Files></AVRWorkspace>

View File

@ -0,0 +1,43 @@
:020000020000FC
:1000000017C118951895189518951895189518955D
:100010001895189518951895189518951895189578
:10002000189518951895FF1829E0001F2A9509F4CE
:100030000895FF1CF11A18F4F10E8894F6CF089475
:10004000F4CFC69A00FFC09800FDC09A01FFC19886
:1000500001FDC19A02FFC29802FDC29A03FFC39834
:1000600003FDC39AC6980895C49A0F930295E9DFD9
:100070000F91E7DFBB27AAEF58D00895C4980F93DC
:100080000295DFDF0F91DDDF02E052D00895059188
:10009000003011F0E9DFFBCF08950A3020F017E3BC
:1000A000010FE2DF089510E3010FDEDF08951F93D3
:1000B0000F9302950F70F1DF0F910F70EEDF1F911C
:1000C0000895EE241AE0AFDFE394FF920030D1F7F9
:1000D00010E30F91010FC8DFEA94D1F7089500688B
:1000E000CDDF08950064CADF0895B89AB99ABA9A24
:1000F000BB9ABC9ABE9AC498C69804E619D013E07D
:1001000003E09FDF05E014D01A95D1F702E099DFF4
:1001100001E00ED008E2B2DF08E0B0DF01E0AEDFC0
:1001200006E0ACDF0CE0AADF08951197F1F708951F
:100130000F93B3E0A8EEF9DFB3E0A8EEF6DF0A957F
:10014000C1F70F91089596988E9AB3E0ACEAEDDF6F
:100150008E98B0E0ACE8E9DF6894869BE894B1E063
:10016000A0EEE3DF089518F4B0E0A2E002C0B0E032
:10017000A0EF8E9ADADF8E98B0E0A8E7D6DF089578
:100180001F9310E00795EFDF13951830D9F71F91F3
:100190000895B0E0A2E08E9AC8DF8E98B0E0AAE0A1
:1001A000C4DFE89486996894B0E0A4E6BEDF0894C2
:1001B0000EF0889408951F9310E0EBDF07951395D8
:1001C0001830D9F71F9108950F931F932F930F9312
:1001D00018E020916800022707950091680010F44C
:1001E00028E102270795009368000F9106950F9369
:1001F0001A9579F70F912F911F910F9108950F93F1
:1002000000E0009368000F91089500916800089540
:1002100069427574746F6E20526561646572000086
:100220006176722D6D63752E6478702E706C00008F
:100230000FED0DBF5ADF01E052DFE0E1F2E027DF12
:1002400001E44DDFE0E2F2E022DF7DDFF6F303E3DD
:1002500097DFD5DFB0DF0030C1F3B6DFC0E6D0E016
:10026000099317E0A8DFB0DF09931A95D9F7CDDF1E
:10027000003059F700E433DFC0E6D0E018E0099120
:0802800016DF1A95E1F7E1CF4A
:00000001FF

View File

@ -0,0 +1,522 @@
AVRASM ver. 2.1.30 F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm Tue Dec 06 21:13:19 2011
EQU SIGNATURE_000 0000001e
EQU SIGNATURE_001 00000091
EQU SIGNATURE_002 0000000a
EQU SREG 0000003f
EQU SPL 0000003d
EQU OCR0B 0000003c
EQU GIMSK 0000003b
EQU EIFR 0000003a
EQU TIMSK 00000039
EQU TIFR 00000038
EQU SPMCSR 00000037
EQU OCR0A 00000036
EQU MCUCR 00000035
EQU MCUSR 00000034
EQU TCCR0B 00000033
EQU TCNT0 00000032
EQU OSCCAL 00000031
EQU TCCR0A 00000030
EQU TCCR1A 0000002f
EQU TCCR1B 0000002e
EQU TCNT1L 0000002c
EQU TCNT1H 0000002d
EQU OCR1AL 0000002a
EQU OCR1AH 0000002b
EQU OCR1BL 00000028
EQU OCR1BH 00000029
EQU CLKPR 00000026
EQU ICR1L 00000024
EQU ICR1H 00000025
EQU GTCCR 00000023
EQU TCCR1C 00000022
EQU WDTCR 00000021
EQU PCMSK 00000020
EQU EEAR 0000001e
EQU EEDR 0000001d
EQU EECR 0000001c
EQU PORTA 0000001b
EQU DDRA 0000001a
EQU PINA 00000019
EQU PORTB 00000018
EQU DDRB 00000017
EQU PINB 00000016
EQU GPIOR2 00000015
EQU GPIOR1 00000014
EQU GPIOR0 00000013
EQU PORTD 00000012
EQU DDRD 00000011
EQU PIND 00000010
EQU USIDR 0000000f
EQU USISR 0000000e
EQU USICR 0000000d
EQU UDR 0000000c
EQU UCSRA 0000000b
EQU UCSRB 0000000a
EQU UBRRL 00000009
EQU ACSR 00000008
EQU UCSRC 00000003
EQU UBRRH 00000002
EQU DIDR 00000001
EQU PORTB0 00000000
EQU PB0 00000000
EQU PORTB1 00000001
EQU PB1 00000001
EQU PORTB2 00000002
EQU PB2 00000002
EQU PORTB3 00000003
EQU PB3 00000003
EQU PORTB4 00000004
EQU PB4 00000004
EQU PORTB5 00000005
EQU PB5 00000005
EQU PORTB6 00000006
EQU PB6 00000006
EQU PORTB7 00000007
EQU PB7 00000007
EQU DDB0 00000000
EQU DDB1 00000001
EQU DDB2 00000002
EQU DDB3 00000003
EQU DDB4 00000004
EQU DDB5 00000005
EQU DDB6 00000006
EQU DDB7 00000007
EQU PINB0 00000000
EQU PINB1 00000001
EQU PINB2 00000002
EQU PINB3 00000003
EQU PINB4 00000004
EQU PINB5 00000005
EQU PINB6 00000006
EQU PINB7 00000007
EQU OCIE0A 00000000
EQU TOIE0 00000001
EQU OCIE0B 00000002
EQU OCF0A 00000000
EQU TOV0 00000001
EQU OCF0B 00000002
EQU OCR0_0 00000000
EQU OCR0_1 00000001
EQU OCR0_2 00000002
EQU OCR0_3 00000003
EQU OCR0_4 00000004
EQU OCR0_5 00000005
EQU OCR0_6 00000006
EQU OCR0_7 00000007
EQU WGM00 00000000
EQU WGM01 00000001
EQU COM0B0 00000004
EQU COM0B1 00000005
EQU COM0A0 00000006
EQU COM0A1 00000007
EQU TCNT0_0 00000000
EQU TCNT0_1 00000001
EQU TCNT0_2 00000002
EQU TCNT0_3 00000003
EQU TCNT0_4 00000004
EQU TCNT0_5 00000005
EQU TCNT0_6 00000006
EQU TCNT0_7 00000007
EQU TCCR0 00000033
EQU CS00 00000000
EQU CS01 00000001
EQU CS02 00000002
EQU WGM02 00000003
EQU FOC0B 00000006
EQU FOC0A 00000007
EQU ICIE1 00000003
EQU TICIE 00000003
EQU OCIE1B 00000005
EQU OCIE1A 00000006
EQU TOIE1 00000007
EQU ICF1 00000003
EQU OCF1B 00000005
EQU OCF1A 00000006
EQU TOV1 00000007
EQU WGM10 00000000
EQU PWM10 00000000
EQU WGM11 00000001
EQU PWM11 00000001
EQU COM1B0 00000004
EQU COM1B1 00000005
EQU COM1A0 00000006
EQU COM1A1 00000007
EQU CS10 00000000
EQU CS11 00000001
EQU CS12 00000002
EQU WGM12 00000003
EQU CTC1 00000003
EQU WGM13 00000004
EQU ICES1 00000006
EQU ICNC1 00000007
EQU FOC1B 00000006
EQU FOC1A 00000007
EQU OCR1AH0 00000000
EQU OCR1AH1 00000001
EQU OCR1AH2 00000002
EQU OCR1AH3 00000003
EQU OCR1AH4 00000004
EQU OCR1AH5 00000005
EQU OCR1AH6 00000006
EQU OCR1AH7 00000007
EQU OCR1AL0 00000000
EQU OCR1AL1 00000001
EQU OCR1AL2 00000002
EQU OCR1AL3 00000003
EQU OCR1AL4 00000004
EQU OCR1AL5 00000005
EQU OCR1AL6 00000006
EQU OCR1AL7 00000007
EQU WDTCSR 00000021
EQU WDP0 00000000
EQU WDP1 00000001
EQU WDP2 00000002
EQU WDE 00000003
EQU WDCE 00000004
EQU WDTOE 00000004
EQU WDP3 00000005
EQU WDIE 00000006
EQU WDIF 00000007
EQU PCIE 00000005
EQU INT0 00000006
EQU INT1 00000007
EQU GIFR 0000003a
EQU PCIF 00000005
EQU INTF0 00000006
EQU INTF1 00000007
EQU UDR0 00000000
EQU UDR1 00000001
EQU UDR2 00000002
EQU UDR3 00000003
EQU UDR4 00000004
EQU UDR5 00000005
EQU UDR6 00000006
EQU UDR7 00000007
EQU USR 0000000b
EQU MPCM 00000000
EQU U2X 00000001
EQU UPE 00000002
EQU PE 00000002
EQU DOR 00000003
EQU FE 00000004
EQU UDRE 00000005
EQU TXC 00000006
EQU RXC 00000007
EQU UCR 0000000a
EQU TXB8 00000000
EQU RXB8 00000001
EQU UCSZ2 00000002
EQU CHR9 00000002
EQU TXEN 00000003
EQU RXEN 00000004
EQU UDRIE 00000005
EQU TXCIE 00000006
EQU RXCIE 00000007
EQU UCPOL 00000000
EQU UCSZ0 00000001
EQU UCSZ1 00000002
EQU USBS 00000003
EQU UPM0 00000004
EQU UPM1 00000005
EQU UMSEL 00000006
EQU UBRR 00000009
EQU ACIS0 00000000
EQU ACIS1 00000001
EQU ACIC 00000002
EQU ACIE 00000003
EQU ACI 00000004
EQU ACO 00000005
EQU ACBG 00000006
EQU ACD 00000007
EQU AIN0D 00000000
EQU AIN1D 00000001
EQU PORTD0 00000000
EQU PD0 00000000
EQU PORTD1 00000001
EQU PD1 00000001
EQU PORTD2 00000002
EQU PD2 00000002
EQU PORTD3 00000003
EQU PD3 00000003
EQU PORTD4 00000004
EQU PD4 00000004
EQU PORTD5 00000005
EQU PD5 00000005
EQU PORTD6 00000006
EQU PD6 00000006
EQU DDD0 00000000
EQU DDD1 00000001
EQU DDD2 00000002
EQU DDD3 00000003
EQU DDD4 00000004
EQU DDD5 00000005
EQU DDD6 00000006
EQU PIND0 00000000
EQU PIND1 00000001
EQU PIND2 00000002
EQU PIND3 00000003
EQU PIND4 00000004
EQU PIND5 00000005
EQU PIND6 00000006
EQU EEARL 0000001e
EQU EEAR0 00000000
EQU EEAR1 00000001
EQU EEAR2 00000002
EQU EEAR3 00000003
EQU EEAR4 00000004
EQU EEAR5 00000005
EQU EEAR6 00000006
EQU EEDR0 00000000
EQU EEDR1 00000001
EQU EEDR2 00000002
EQU EEDR3 00000003
EQU EEDR4 00000004
EQU EEDR5 00000005
EQU EEDR6 00000006
EQU EEDR7 00000007
EQU EERE 00000000
EQU EEPE 00000001
EQU EEWE 00000001
EQU EEMPE 00000002
EQU EEMWE 00000002
EQU EERIE 00000003
EQU EEPM0 00000004
EQU EEPM1 00000005
EQU PORTA0 00000000
EQU PA0 00000000
EQU PORTA1 00000001
EQU PA1 00000001
EQU PORTA2 00000002
EQU PA2 00000002
EQU DDA0 00000000
EQU DDA1 00000001
EQU DDA2 00000002
EQU PINA0 00000000
EQU PINA1 00000001
EQU PINA2 00000002
EQU SREG_C 00000000
EQU SREG_Z 00000001
EQU SREG_N 00000002
EQU SREG_V 00000003
EQU SREG_S 00000004
EQU SREG_H 00000005
EQU SREG_T 00000006
EQU SREG_I 00000007
EQU SPMEN 00000000
EQU PGERS 00000001
EQU PGWRT 00000002
EQU RFLB 00000003
EQU CTPB 00000004
EQU ISC00 00000000
EQU ISC01 00000001
EQU ISC10 00000002
EQU ISC11 00000003
EQU SM0 00000004
EQU SM 00000004
EQU SE 00000005
EQU SM1 00000006
EQU PUD 00000007
EQU CLKPS0 00000000
EQU CLKPS1 00000001
EQU CLKPS2 00000002
EQU CLKPS3 00000003
EQU CLKPCE 00000007
EQU PORF 00000000
EQU EXTRF 00000001
EQU BORF 00000002
EQU WDRF 00000003
EQU CAL0 00000000
EQU CAL1 00000001
EQU CAL2 00000002
EQU CAL3 00000003
EQU CAL4 00000004
EQU CAL5 00000005
EQU CAL6 00000006
EQU SFIOR 00000023
EQU PSR10 00000000
EQU PCINT0 00000000
EQU PCINT1 00000001
EQU PCINT2 00000002
EQU PCINT3 00000003
EQU PCINT4 00000004
EQU PCINT5 00000005
EQU PCINT6 00000006
EQU PCINT7 00000007
EQU GPIOR20 00000000
EQU GPIOR21 00000001
EQU GPIOR22 00000002
EQU GPIOR23 00000003
EQU GPIOR24 00000004
EQU GPIOR25 00000005
EQU GPIOR26 00000006
EQU GPIOR27 00000007
EQU GPIOR10 00000000
EQU GPIOR11 00000001
EQU GPIOR12 00000002
EQU GPIOR13 00000003
EQU GPIOR14 00000004
EQU GPIOR15 00000005
EQU GPIOR16 00000006
EQU GPIOR17 00000007
EQU GPIOR00 00000000
EQU GPIOR01 00000001
EQU GPIOR02 00000002
EQU GPIOR03 00000003
EQU GPIOR04 00000004
EQU GPIOR05 00000005
EQU GPIOR06 00000006
EQU GPIOR07 00000007
EQU USIDR0 00000000
EQU USIDR1 00000001
EQU USIDR2 00000002
EQU USIDR3 00000003
EQU USIDR4 00000004
EQU USIDR5 00000005
EQU USIDR6 00000006
EQU USIDR7 00000007
EQU USICNT0 00000000
EQU USICNT1 00000001
EQU USICNT2 00000002
EQU USICNT3 00000003
EQU USIDC 00000004
EQU USIPF 00000005
EQU USIOIF 00000006
EQU USISIF 00000007
EQU USITC 00000000
EQU USICLK 00000001
EQU USICS0 00000002
EQU USICS1 00000003
EQU USIWM0 00000004
EQU USIWM1 00000005
EQU USIOIE 00000006
EQU USISIE 00000007
EQU LB1 00000000
EQU LB2 00000001
EQU CKSEL0 00000000
EQU CKSEL1 00000001
EQU CKSEL2 00000002
EQU CKSEL3 00000003
EQU SUT0 00000004
EQU SUT1 00000005
EQU CKOUT 00000006
EQU CKDIV8 00000007
EQU BODLEVEL0 00000000
EQU BODLEVEL1 00000001
EQU BODLEVEL2 00000002
EQU EESAVE 00000003
EQU WDTON 00000004
EQU SPIEN 00000005
EQU DWEN 00000006
EQU RSTDISBL 00000007
EQU SELFPRGEN 00000000
DEF XH r27
DEF XL r26
DEF YH r29
DEF YL r28
DEF ZH r31
DEF ZL r30
EQU FLASHEND 000003ff
EQU IOEND 0000003f
EQU SRAM_START 00000060
EQU SRAM_SIZE 00000080
EQU RAMEND 000000df
EQU XRAMEND 00000000
EQU E2END 0000007f
EQU EEPROMEND 0000007f
EQU EEADRBITS 00000007
EQU NRWW_START_ADDR 00000000
EQU NRWW_STOP_ADDR 000003ff
EQU RWW_START_ADDR 00000000
EQU RWW_STOP_ADDR 00000000
EQU PAGESIZE 00000010
EQU INT0addr 00000001
EQU INT1addr 00000002
EQU ICP1addr 00000003
EQU OC1Aaddr 00000004
EQU OC1addr 00000004
EQU OVF1addr 00000005
EQU OVF0addr 00000006
EQU URXCaddr 00000007
EQU URXC0addr 00000007
EQU UDREaddr 00000008
EQU UDRE0addr 00000008
EQU UTXCaddr 00000009
EQU UTXC0addr 00000009
EQU ACIaddr 0000000a
EQU PCIaddr 0000000b
EQU OC1Baddr 0000000c
EQU OC0Aaddr 0000000d
EQU OC0Baddr 0000000e
EQU USI_STARTaddr 0000000f
EQU USI_OVFaddr 00000010
EQU ERDYaddr 00000011
EQU WDTaddr 00000012
EQU INT_VECTORS_SIZE 00000013
DSEG SerialNumber 00000060
CSEG ProgramEntryPoint 00000118
EQU LCD_PORT 00000018
EQU LCD_DDR 00000017
EQU LCD_PIN 00000016
EQU LCD_D4 00000000
EQU LCD_D5 00000001
EQU LCD_D6 00000002
EQU LCD_D7 00000003
EQU LCD_RS 00000004
EQU LCD_EN 00000006
DEF drem8u r15
DEF dres8u r16
DEF dd8u r16
DEF dv8u r17
DEF dcnt8u r18
CSEG div8u 00000013
CSEG d8u_1 00000015
CSEG d8u_2 00000019
CSEG d8u_3 0000001f
CSEG LCD_WriteNibble 00000021
CSEG LCD_WriteData 00000034
CSEG Wait4xCycles 00000095
CSEG LCD_WriteCommand 0000003e
CSEG WaitMiliseconds 00000098
CSEG LCD_WriteString 00000047
CSEG exit 0000004c
CSEG LCD_WriteHexDigit 0000004d
CSEG Num 00000053
CSEG LCD_WriteHex8 00000057
CSEG LCD_WriteDecimal 00000061
CSEG LCD_WriteDecimalLoop 00000062
CSEG LCD_WriteDecimalLoop2 00000068
CSEG LCD_SetAddressDD 0000006f
CSEG LCD_SetAddressCG 00000072
CSEG LCD_Init 00000075
CSEG InitLoop 00000080
CSEG WaitMsLoop 00000099
EQU OW_PORT 00000012
EQU OW_PIN 00000010
EQU OW_DDR 00000011
EQU OW_DQ 00000006
DEF OWCount r17
CSEG OWReset 000000a3
CSEG OWWriteBit 000000b3
CSEG OWWriteZero 000000b7
CSEG OWWriteOne 000000b9
CSEG OWWriteByte 000000c0
CSEG OWWriteLoop 000000c2
CSEG OWReadBit 000000c9
CSEG OWReadBitEnd 000000da
CSEG OWReadByte 000000db
CSEG OWReadLoop 000000dd
DSEG _crc 00000068
CSEG CRC8Update 000000e4
CSEG CRC8L 000000e9
CSEG CRC8zero 000000f2
CSEG CRC8Init 000000ff
CSEG GetCRC8 00000105
CSEG Text1 00000108
CSEG Text2 00000110
CSEG MainLoop 00000125
CSEG StoreLoop 00000132
CSEG LoadLoop 0000013f

Binary file not shown.

View File

@ -0,0 +1,75 @@
<ASSEMBLER_INFO>
<VERSION>2.1.30</VERSION>
<DEVICE>ATtiny2313</DEVICE>
<WORKING_DIR>F:\WORK\uK\AVR\Projects\ibutton-number-read</WORKING_DIR>
<INCLUDE_PATH>
<DIR>C:\Program Files (x86)\Atmel\AVR Tools\AvrAssembler2\Appnotes</DIR>
</INCLUDE_PATH>
<SOURCE_FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</SOURCE_FILE>
<INCLUDED_FILES>
<FILE>C:\Program Files (x86)\Atmel\AVR Tools\AvrAssembler2\Appnotes\tn2313def.inc</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\vectors.asm</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.inc</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\div8u.asm</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\wait.asm</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE>
</INCLUDED_FILES>
<OBJECT_FILES>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.obj</FILE>
</OBJECT_FILES>
<HEX_FILES>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.hex</FILE>
</HEX_FILES>
<OUTPUT_FILES>
<FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\ibutton-number-read.map</FILE>
</OUTPUT_FILES>
<LABELS>
<SerialNumber><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>17</LINE></SerialNumber>
<ProgramEntryPoint><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>42</LINE></ProgramEntryPoint>
<div8u><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\div8u.asm</FILE><LINE>12</LINE></div8u>
<d8u_1><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\div8u.asm</FILE><LINE>15</LINE></d8u_1>
<d8u_2><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\div8u.asm</FILE><LINE>20</LINE></d8u_2>
<d8u_3><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\div8u.asm</FILE><LINE>27</LINE></d8u_3>
<LCD_WriteNibble><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>34</LINE></LCD_WriteNibble>
<LCD_WriteData><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>62</LINE></LCD_WriteData>
<Wait4xCycles><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\wait.asm</FILE><LINE>24</LINE></Wait4xCycles>
<LCD_WriteCommand><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>77</LINE></LCD_WriteCommand>
<WaitMiliseconds><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\wait.asm</FILE><LINE>32</LINE></WaitMiliseconds>
<LCD_WriteString><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>90</LINE></LCD_WriteString>
<exit><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>96</LINE></exit>
<LCD_WriteHexDigit><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>101</LINE></LCD_WriteHexDigit>
<Num><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>108</LINE></Num>
<LCD_WriteHex8><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>116</LINE></LCD_WriteHex8>
<LCD_WriteDecimal><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>131</LINE></LCD_WriteDecimal>
<LCD_WriteDecimalLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>133</LINE></LCD_WriteDecimalLoop>
<LCD_WriteDecimalLoop2><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>141</LINE></LCD_WriteDecimalLoop2>
<LCD_SetAddressDD><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>152</LINE></LCD_SetAddressDD>
<LCD_SetAddressCG><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>159</LINE></LCD_SetAddressCG>
<LCD_Init><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>166</LINE></LCD_Init>
<InitLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\hd44780.asm</FILE><LINE>182</LINE></InitLoop>
<WaitMsLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\wait.asm</FILE><LINE>34</LINE></WaitMsLoop>
<OWReset><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>17</LINE></OWReset>
<OWWriteBit><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>43</LINE></OWWriteBit>
<OWWriteZero><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>48</LINE></OWWriteZero>
<OWWriteOne><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>51</LINE></OWWriteOne>
<OWWriteByte><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>63</LINE></OWWriteByte>
<OWWriteLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>66</LINE></OWWriteLoop>
<OWReadBit><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>77</LINE></OWReadBit>
<OWReadBitEnd><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>95</LINE></OWReadBitEnd>
<OWReadByte><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>100</LINE></OWReadByte>
<OWReadLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\1-wire.asm</FILE><LINE>103</LINE></OWReadLoop>
<_crc><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>13</LINE></_crc>
<CRC8Update><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>21</LINE></CRC8Update>
<CRC8L><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>28</LINE></CRC8L>
<CRC8zero><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>37</LINE></CRC8zero>
<CRC8Init><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>53</LINE></CRC8Init>
<GetCRC8><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\crc8.asm</FILE><LINE>62</LINE></GetCRC8>
<Text1><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>34</LINE></Text1>
<Text2><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>36</LINE></Text2>
<MainLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>63</LINE></MainLoop>
<StoreLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>84</LINE></StoreLoop>
<LoadLoop><FILE>F:\WORK\uK\AVR\Projects\ibutton-number-read\main.asm</FILE><LINE>101</LINE></LoadLoop>
</LABELS>
</ASSEMBLER_INFO>

View File

@ -0,0 +1,107 @@
;------------------------------------------------------------------------------
; iButton serial number reader
; http://avr-mcu.dxp.pl
; e-mail: radek(at)dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
.include "tn2313def.inc"
;------------------------------------------------------------------------------
; Defines
;------------------------------------------------------------------------------
#define F_CPU 8000000
;------------------------------------------------------------------------------
; Data segment, variable definitions
;------------------------------------------------------------------------------
.dseg
SerialNumber: .byte 8
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg
;------------------------------------------------------------------------------
; Include required files
;------------------------------------------------------------------------------
#include "vectors.asm"
#include "hd44780.asm"
#include "wait.asm"
#include "1-wire.asm"
#include "crc8.asm"
;------------------------------------------------------------------------------
; Constants definition
;------------------------------------------------------------------------------
Text1 :
.db "iButton Reader",0,0
Text2 :
.db "avr-mcu.dxp.pl",0,0
;------------------------------------------------------------------------------
; Program entry point
;------------------------------------------------------------------------------
ProgramEntryPoint:
ldi r16, LOW(RAMEND) ; Initialize stack pointer
out SPL, r16 ;
rcall LCD_Init ; Initialize LCD
ldi r16, (HD44780_LINE0 + 1) ;
rcall LCD_SetAddressDD ; Set Display Data address to (0,1)
ldi ZL, LOW(Text1 << 1) ; Load string address to Z
ldi ZH, HIGH(Text1<< 1) ;
rcall LCD_WriteString ; Display string
ldi r16, (HD44780_LINE1 + 1) ;
rcall LCD_SetAddressDD ; Set Display Data address to (1,1)
ldi ZL, LOW(Text2 << 1) ;
ldi ZH, HIGH(Text2<< 1) ; Load string address to Z
rcall LCD_WriteString ; Display string
MainLoop:
rcall OWReset ; One wire reset
brts MainLoop ; If device not present go to MainLoop
ldi r16, 0x33 ; Write ReadRom command
rcall OWWriteByte ;
rcall CRC8Init ; Initialize CRC8 value
rcall OWReadByte ; Read first byte (Family ID)
cpi r16,0 ; If first byte equal to zero, go to MainLoop
breq MainLoop ; (short circuit on one wire bus)
rcall CRC8Update ; Update the CRC
ldi YL, LOW(SerialNumber) ;
ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table
st Y+, r16 ; Store first byte to table, and increment pointer
ldi r17, 7 ; 7 bytes remaining
StoreLoop:
rcall OWReadByte ; read next byte
rcall CRC8Update ; update the CRC
st Y+, r16 ; store next byte to table, and increment pointer
dec r17 ; decrement loop counter
brne StoreLoop ; if greater than zero, jump to StoreLoop
rcall GetCRC8 ; Read computet CRC8
cpi r16,0 ; copmare with zero
brne MainLoop ; if not equal, jump to MainLoop (bad CRC)
; else
ldi r16, (HD44780_LINE1 + 0) ;
rcall LCD_SetAddressDD ; Set DisplayData address to (0,1)
ldi YL, LOW(SerialNumber) ;
ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table
ldi r17,8 ; 8 digits to display
LoadLoop:
ld r16, Y+ ; load to r16 byte from table
rcall LCD_WriteHex8 ; display it on LCD in HEX
dec r17 ; decrement loop conouter
brne LoadLoop ; if not zero, jump to LoadLoop
rjmp MainLoop ; jump to MainLoop
;------------------------------------------------------------------------------
; End of file
;------------------------------------------------------------------------------

View File

@ -0,0 +1,39 @@
.cseg
.org 0 ; Reset
rjmp ProgramEntryPoint
.org INT0addr ; External Interrupt Request 0
reti
.org INT1addr ; External Interrupt Request 1
reti
.org ICP1addr ; Timer/Counter1 Capture Event
reti
.org OC1Aaddr ; Timer/Counter1 Compare Match A
reti
.org OVF1addr ; Timer/Counter1 Overflow
reti
.org OVF0addr ; Timer/Counter0 Overflow
reti
.org URXCaddr ; USART, Rx Complete
reti
.org UDREaddr ; USART Data Register Empty
reti
.org UTXCaddr ; USART, Tx Complete
reti
.org ACIaddr ; Analog Comparator
reti
.org PCIaddr ;
reti
.org OC1Baddr ;
reti
.org OC0Aaddr ;
reti
.org OC0Baddr ;
reti
.org USI_STARTaddr ; USI Start Condition
reti
.org USI_OVFaddr ; USI Overflow
reti
.org ERDYaddr ;
reti
.org WDTaddr ; Watchdog Timer Overflow
reti

View File

@ -0,0 +1,47 @@
;------------------------------------------------------------------------------
; Busy-wait loops utilities module
; For F_CPU >= 4MHz
; http://avr-mcu.dxp.pl
; e-mail : radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
#ifndef F_CPU
#error "F_CPU must be defined!"
#endif
#if F_CPU < 4000000
#warning "F_CPU too low, possible wrong delay"
#endif
#define CYCLES_PER_US (F_CPU/1000000)
#define C4PUS (CYCLES_PER_US/4)
#define DVUS(x) (C4PUS*x)
;------------------------------------------------------------------------------
; Input : XH:XL - number of CPU cycles to wait (divided by four)
;------------------------------------------------------------------------------
Wait4xCycles:
sbiw XH:XL, 1 ; x-- (2 cycles)
brne Wait4xCycles ; jump if not zero (2 cycles)
ret
;------------------------------------------------------------------------------
; Input : r16 - number of miliseconds to wait
;------------------------------------------------------------------------------
WaitMiliseconds:
push r16
WaitMsLoop:
ldi XH,HIGH(DVUS(500))
ldi XL,LOW(DVUS(500))
rcall Wait4xCycles
ldi XH,HIGH(DVUS(500))
ldi XL,LOW(DVUS(500))
rcall Wait4xCycles
dec r16
brne WaitMsLoop
pop r16
ret
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------

254
main.asm
View File

@ -1,90 +1,198 @@
; ;------------------------------------------------------------------------------
; chenillarEssai3.asm ; iButton serial number reader
; ; Addapter pour lire le 18b20 par http://adriy.be
; Created: 19-03-18 13:13:56 ; http://avr-mcu.dxp.pl
; Author : Adrien ; e-mail: radek(at)dxp.pl
; ; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Defines
;------------------------------------------------------------------------------
#define F_CPU 16000000
;Table 3. DS18B20 Function Command Set p12
#define ReadRom 0x33
#define SkipRom 0xcc
#define ConvertTemp 0x44 ; Initiates temperature conversion.
#define WScratch 0x4e ; Writes data into scratchpad bytes 2, 3, and4 (TH, TL, and configuration registers).
#define RScratch 0xbe ; Reads the entire scratchpad including theCRC byte.
;------------------------------------------------------------------------------
; Data segment, variable definitions
;------------------------------------------------------------------------------
.dseg .dseg
.def rtmp = r16
.def rdec = r17
.def rsens = r18
SerialNumber: .byte 8
;------------------------------------------------------------------------------
; Code segment
;------------------------------------------------------------------------------
.cseg .cseg
.include "m328pdef.inc" ;------------------------------------------------------------------------------
; Include required files
;------------------------------------------------------------------------------
#include "vectors.asm"
#include "hd44780.asm"
#include "wait.asm"
#include "1-wire.asm"
#include "crc8.asm"
;------------------------------------------------------------------------------
; Constants definition
;------------------------------------------------------------------------------
Text1 :
.db "iButton Reader",0,0
Text2 :
.db "avr-mcu.dxp.pl",0,0
Tp :
.db ".",0,0
;------------------------------------------------------------------------------
; Program entry point
;------------------------------------------------------------------------------
ProgramEntryPoint:
ldi r16, LOW(RAMEND) ; Initialize stack pointer
out SPL, r16 ;
.org 0x0000 rcall LCD_Init ; Initialize LCD
jmp RESET
.org OC0Aaddr ldi r16, (HD44780_LINE0 + 1) ;
jmp TIM0_COMPA ; Timer0 CompareA rcall LCD_SetAddressDD ; Set Display Data address to (0,1)
.org OVF0addr
jmp TIM0_OVF ldi ZL, LOW(Text1 << 1) ; Load string address to Z
ldi ZH, HIGH(Text1<< 1) ;
rcall LCD_WriteString ; Display string
ldi r16, (HD44780_LINE1 + 1) ;
rcall LCD_SetAddressDD ; Set Display Data address to (1,1);
;ldi ZL, LOW(Text2 << 1) ;
;ldi ZH, HIGH(Text2<< 1) ; Load string address to Z
;rcall LCD_WriteString ; Display string
ConfigResolTo10Bits:
rcall OWReset
brts ConfigResolTo10Bits
ldi r16, SkipRom ; Write Skip Rom one wire in "single-drop"
rcall OWWriteByte
ldi r16, WScratch
rcall OWWriteByte
clr r16
rcall OWWriteByte ;th,tl
rcall OWWriteByte ;th,tl
ldi r16, 63
rcall OWWriteByte ;resol
.org 0x0100 MainLoop:
ldi r16, (HD44780_LINE1 + 1) ;
rcall LCD_SetAddressDD ; Set Display Data address to (1,1);
rcall OWReset ; One wire reset
brts MainLoop ; If device not present go to MainLoop
RESET: rcall TempRequest
ldi rtmp, HIGH(RAMEND) ;Charge la valeur haute de l?adresse en fin m?moire RAM rcall MainReadTemp
out SPH, rtmp ;Positionne le pointeur de pile haut sur cette adresse rcall ConvertTempForLCD
ldi rtmp, LOW(RAMEND) ;Charge la valeur basse de l?adresse en fin m?moire RAM
out SPL, rtmp ;Positionne le pointeur de pile bas sur cette adresse
; Replace with your application code
ser rtmp ;Port en sortie (les bits du port sont mis ? 1, soit en sortie)
out DDRD, rtmp ;Ecriture sur le
clr rtmp ;Port en bas (les bits du port sont mis ? 0, Led ?teinte)
ldi rtmp, 0x01
out PORTD, rtmp ;PINB1 Mis ? 1
clr rsens
;_____________________________________________________________________________
;Setup Timer0
;_____________________________________________________________________________
CLR rtmp
OUT TCCR0A, rtmp ;Normal port op
LDI rtmp, 0x01
OUT TCCR0B, rtmp ; No Force, No wave, Clk from precal/1024, 7.8125Khz, 128?s
ldi rtmp, 0x02
sts TIMSK0, rtmp ; OCR0A Interrupt Enable
CLR rtmp
OUT TCNT0, rtmp ;
LDI rtmp, 0xff
OUT OCR0A, rtmp ; 256*128?s = 16ms
LDI rdec, 0xFF
;_____________________________________________________________________________
;Setup PWM Timer0
;_____________________________________________________________________________
SEI ;rcall CRC8Init ; Initialize CRC8 value
jmp LoadLoop
rcall OWReadByte ; Read first byte (Family ID)
cpi r16,0 ; If first byte equal to zero, go to MainLoop
breq MainLoop ; (short circuit on one wire bus)
rcall CRC8Update ; Update the CRC
ldi YL, LOW(SerialNumber) ;
ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table
st Y+, r16 ; Store first byte to table, and increment pointer
ldi r17, 7 ; 7 bytes remaining
StoreLoop:
rcall OWReadByte ; read next byte
rcall CRC8Update ; update the CRC
st Y+, r16 ; store next byte to table, and increment pointer
dec r17 ; decrement loop counter
brne StoreLoop ; if greater than zero, jump to StoreLoop
rcall GetCRC8 ; Read computet CRC8
cpi r16,0 ; copmare with zero
brne MainLoop ; if not equal, jump to MainLoop (bad CRC)
; else
ldi r16, (HD44780_LINE1 + 0) ;
rcall LCD_SetAddressDD ; Set DisplayData address to (0,1)
ldi YL, LOW(SerialNumber) ;
ldi YH, HIGH(SerialNumber) ; Load to Y address of SerialNumber table
ldi r17,2 ; 8 digits to display
LoadLoop:
push r16
mov r16, XL ; load to r16 byte from table
push r16
ldi r19,0xF0
and r16,r19
rcall bin2bcd8
lsr r16
lsr r16
lsr r16
lsr r16
rcall LCD_WriteHexDigit ; display it on LCD in HEX
pop r16
rcall bin2bcd8
ldi r18,0x0F
and r16,r18
rcall LCD_WriteHexDigit ; display it on LCD in HEX
start:
mov r16, r18 ; load to r16 byte from table
push r16
ldi r19,0xF0
and r16,r19
rcall bin2bcd8
lsr r16
lsr r16
lsr r16
lsr r16
rcall LCD_WriteHexDigit ; display it on LCD in HEX
pop r16
rcall bin2bcd8
ldi r18,0x0F
and r16,r18
rcall LCD_WriteHexDigit ; display it on LCD in HEX
nop nop
nop nop
nop nop
jmp PC-2 jmp MainLoop
brne LoadLoop ; if not zero, jump to LoadLoop
rjmp MainLoop ; jump to MainLoop
TIM0_COMPA: ;------------------------------------------------------------------------------
dec rdec ; End of file
BRNE PC+7 ;------------------------------------------------------------------------------
in rtmp, PORTD
lsl rtmp ;Shift left
BRCC PC+2; Si le cary est ? 0 rtmp est dif de 0x00 Si carry est ? 1, rtmp = 0x00 donc on le met ? 0x01
ldi rtmp, 0x01
out PORTD, rtmp
ldi r18, 0xff
ldi rtmp, 0x00
out TCNT0, rtmp
reti ;Fin de l?interruption
TIM0_OVF:
dec rdec
BRNE PC+1
in rtmp, PORTD
lsl rtmp ;Shift left ;======= Converting from HEX to BCD ====================================================https://evileg.com/en/post/19/
BRCC PC+2; Si le cary est ? 0 rtmp est dif de 0x00 Si carry est ? 1, rtmp = 0x00 donc on le met ? 0x01 ;*****************************************************
ldi rtmp, 0x01 ;* "bin2BCD8" - 8-bit Binary to BCD conversion
out PORTD, rtmp ;* This subroutine converts an 8-bit number (temp) to a 2-digit
reti ;* i.e 0x15 becomes 0x21
;* result in temp
;**********************************************************
;.def tBCD = r21 ;add this to main asm file
;
bin2bcd8:
clr r21 ;clear temp reg
bBCD8_1:
subi r16,10 ;input = input - 10
brcs bBCD8_2 ;abort if carry set
subi r21,-$10 ;tBCD = tBCD + 10
rjmp bBCD8_1 ;loop again
bBCD8_2:
subi r16,-10 ;compensate extra subtraction
add r16,r21
ret

92
vectors.asm Normal file
View File

@ -0,0 +1,92 @@
.cseg
.org 0 ; Reset
rjmp ProgramEntryPoint
.org INT0addr
reti
.org INT1addr
reti
.org PCI0addr
reti
.org PCI1addr
reti
.org PCI2addr
reti
.org WDTaddr
reti
.org OC2Aaddr
reti
.org OC2Baddr
reti
.org OVF2addr
reti
.org ICP1addr
reti
.org OC1Aaddr
reti
.org OC1Baddr
reti
.org OVF1addr
reti
.org OC0Aaddr
reti
.org OC0Baddr
reti
.org OVF0addr
reti
.org SPIaddr
reti
.org URXCaddr
reti
.org UDREaddr
reti
.org UTXCaddr
reti
.org ADCCaddr
reti
.org ERDYaddr
reti
.org ACIaddr
reti
.org TWIaddr
reti
.org SPMRaddr
reti
; .org INT0addr ; External Interrupt Request 0
; reti
; .org INT1addr ; External Interrupt Request 1
; reti
; .org ICP1addr ; Timer/Counter1 Capture Event
; reti
; .org OC1Aaddr ; Timer/Counter1 Compare Match A
; reti
; .org OVF1addr ; Timer/Counter1 Overflow
; reti
; .org OVF0addr ; Timer/Counter0 Overflow
; reti
; .org URXCaddr ; USART, Rx Complete
; reti
; .org UDREaddr ; USART Data Register Empty
; reti
; .org UTXCaddr ; USART, Tx Complete
; reti
; .org ACIaddr ; Analog Comparator
; reti
; .org PCIaddr ;
; reti
; .org OC1Baddr ;
; reti
; .org OC0Aaddr ;
; reti
; .org OC0Baddr ;
; reti
; .org USI_STARTaddr ; USI Start Condition
; reti
; .org USI_OVFaddr ; USI Overflow
; reti
; .org ERDYaddr ;
; reti
; .org WDTaddr ; Watchdog Timer Overflow
; reti

47
wait.asm Normal file
View File

@ -0,0 +1,47 @@
;------------------------------------------------------------------------------
; Busy-wait loops utilities module
; For F_CPU >= 4MHz
; http://avr-mcu.dxp.pl
; e-mail : radek@dxp.pl
; (c) Radoslaw Kwiecien
;------------------------------------------------------------------------------
#ifndef F_CPU
#error "F_CPU must be defined!"
#endif
#if F_CPU < 4000000
#warning "F_CPU too low, possible wrong delay"
#endif
#define CYCLES_PER_US (F_CPU/1000000)
#define C4PUS (CYCLES_PER_US/4)
#define DVUS(x) (C4PUS*x)
;------------------------------------------------------------------------------
; Input : XH:XL - number of CPU cycles to wait (divided by four)
;------------------------------------------------------------------------------
Wait4xCycles:
sbiw XH:XL, 1 ; x-- (2 cycles)
brne Wait4xCycles ; jump if not zero (2 cycles)
ret
;------------------------------------------------------------------------------
; Input : r16 - number of miliseconds to wait
;------------------------------------------------------------------------------
WaitMiliseconds:
push r16
WaitMsLoop:
ldi XH,HIGH(DVUS(500))
ldi XL,LOW(DVUS(500))
rcall Wait4xCycles
ldi XH,HIGH(DVUS(500))
ldi XL,LOW(DVUS(500))
rcall Wait4xCycles
dec r16
brne WaitMsLoop
pop r16
ret
;------------------------------------------------------------------------------
;
;------------------------------------------------------------------------------