final_countdown.asm
1 | .include "8535def.inc"
| 2 |
| 3 |
| 4 | RJMP reset
| 5 | RETI
| 6 | RETI
| 7 | RETI
| 8 | RETI
| 9 | RETI
| 10 | RETI
| 11 | RETI
| 12 | RETI
| 13 | RJMP start
| 14 | RETI
| 15 | RETI
| 16 | RETI
| 17 | RETI
| 18 | RETI
| 19 | RETI
| 20 | RETI
| 21 |
| 22 |
| 23 |
| 24 | .def temp1 = r16
| 25 | .def temp2 = r17
| 26 | .def temp3 = r18
| 27 | .def loop1 = r19
| 28 | .def loop2 = r20
| 29 | .def ztau = r1
| 30 | .def taus = r2
| 31 | .def hund = r3
| 32 | .def zehn = r4
| 33 | .def ein = r5
| 34 | .def konst = r21
| 35 |
| 36 |
| 37 | .equ temp_lsb = 0x060
| 38 | .equ temp_msb = 0x061
| 39 | .equ th_reg = 0x062
| 40 | .equ tl_reg = 0x063
| 41 | .equ res1 = 0x064
| 42 | .equ res2 = 0x065
| 43 | .equ count_re = 0x066
| 44 | .equ count_pc = 0x067
| 45 | .equ crc = 0x068
| 46 |
| 47 |
| 48 | reset:
| 49 | clr temp1
| 50 | clr temp2
| 51 | clr temp3
| 52 | clr loop1
| 53 | clr loop2
| 54 |
| 55 | sts temp_lsb, temp1
| 56 | sts temp_msb, temp1
| 57 | sts th_reg , temp1
| 58 | sts tl_reg , temp1
| 59 | sts res1 , temp1
| 60 | sts res2 , temp1
| 61 | sts count_re, temp1
| 62 | sts count_pc, temp1
| 63 | sts crc , temp1
| 64 |
| 65 | ldi temp1, low(ramend)
| 66 | out spl, temp1
| 67 | ldi temp1, high(ramend)
| 68 | out sph, temp1
| 69 |
| 70 |
| 71 | ldi temp1, 0xFF
| 72 | out ddrc, temp1
| 73 |
| 74 | rcall lcd_init
| 75 | rcall lcd_clear
| 76 | ldi r23,3
| 77 |
| 78 | rcall init
| 79 | rcall skip_rom
| 80 | rcall convert_t
| 81 |
| 82 | rcall timerinit
| 83 | sei
| 84 | ;------------------------------------------------------------------------------
| 85 | warten: rjmp warten
| 86 |
| 87 | ausgabe: ; alle sekunden
| 88 | inc r23
| 89 | cpi r23,4 ; alle 4 sekunden abfragen
| 90 | breq main
| 91 | ret
| 92 |
| 93 | main: clr r23
| 94 | rcall init
| 95 | rcall skip_rom
| 96 | rcall convert_t
| 97 | rcall init
| 98 | rcall skip_rom
| 99 | rcall read_scratchpad
| 100 | rcall init
| 101 |
| 102 |
| 103 | weiter: ; schauen ob plus oder minus
| 104 | lds temp3, temp_msb
| 105 | sbrs temp3, 0
| 106 | rjmp plus
| 107 |
| 108 | ldi temp1, 0b10000001 ; minus
| 109 | rcall lcd_command_1
| 110 | ldi temp1, 45
| 111 | rcall lcd_data_1
| 112 | rjmp weiter1
| 113 |
| 114 | plus: ldi temp1, 0b10000001 ;plus
| 115 | rcall lcd_command_1
| 116 | ldi temp1, 43
| 117 | rcall lcd_data_1
| 118 | rjmp weiter1
| 119 |
| 120 | weiter1:
| 121 | lds temp3, temp_lsb ; ,5 ja nein
| 122 | sbrs temp3,0
| 123 | rjmp nein
| 124 |
| 125 | ldi temp1, 0b10000101
| 126 | rcall lcd_command_1
| 127 | ldi temp1, 44
| 128 | rcall lcd_data_1
| 129 | ldi temp1, 53
| 130 | rcall lcd_data_1
| 131 | rjmp weiter2
| 132 |
| 133 | nein: ldi temp1, 0b10000101 ; ,0
| 134 | rcall lcd_command_1
| 135 | ldi temp1, 44
| 136 | rcall lcd_data_1
| 137 | ldi temp1, 48
| 138 | rcall lcd_data_1
| 139 | rjmp weiter2
| 140 |
| 141 | weiter2:
| 142 | ror temp3 ; rechtsrollen
| 143 | mov xl, temp3
| 144 | ldi xh, 0x00
| 145 |
| 146 | rcall bin2ascii
| 147 |
| 148 | ldi temp1, 0b10000011
| 149 | rcall lcd_command_1
| 150 |
| 151 | mov temp1,r4
| 152 | rcall lcd_data_1
| 153 | mov temp1,r5
| 154 | rcall lcd_data_1
| 155 |
| 156 | ldi temp1, 0b10001000
| 157 | rcall lcd_command_1
| 158 |
| 159 | ldi temp1, 223 ; °
| 160 | rcall lcd_data_1
| 161 |
| 162 | ldi temp1, 'C' ; C
| 163 | rcall lcd_data_1
| 164 |
| 165 | ret
| 166 |
| 167 | ;------------------------------------------------------------------------------
| 168 |
| 169 | init: sbi ddrb, 0 ;pb0 ausgang
| 170 | cbi portb, 0 ;signal auf low ziehen
| 171 | rcall wait500us ;und 500us halten
| 172 |
| 173 | cbi ddrb,0
| 174 | rcall wait70us ;wartet dazu 70us
| 175 |
| 176 | wait_presence_pulse:
| 177 | sbic pinb,0
| 178 | rjmp wait_presence_pulse
| 179 |
| 180 | rcall wait410us ;410us warten
| 181 |
| 182 |
| 183 |
| 184 | ret
| 185 |
| 186 | ;------------------------------------------------------------------------------
| 187 |
| 188 | write_1:
| 189 | sbi ddrb, 0 ;pb0 ausgang
| 190 | cbi portb, 0 ;signal auf low ziehen
| 191 |
| 192 | rcall wait6us ;und 6us halten
| 193 |
| 194 | cbi ddrb, 0 ;lässt bus los
| 195 | rcall wait65us ;wartet dazu 65us
| 196 |
| 197 | ret
| 198 |
| 199 |
| 200 | ;-----------------------------------------------------------------------------
| 201 |
| 202 |
| 203 | write_0:sbi ddrb, 0 ;pb0 ausgang
| 204 | cbi portb, 0 ;signal auf low ziehen
| 205 |
| 206 | rcall wait60us ;und 60us halten
| 207 |
| 208 | cbi ddrb, 0 ;lässt bus los
| 209 | rcall wait10us ;wartet dazu 10us
| 210 |
| 211 | ret
| 212 |
| 213 |
| 214 | ;-----------------------------------------------------------------------------
| 215 |
| 216 |
| 217 | read_bit:
| 218 | clr temp3 ;löschen
| 219 | ldi temp1, 8 ;für 8mal durchführen (8bit)
| 220 |
| 221 | read_bit1:
| 222 |
| 223 | ror temp3 ;rechts rollen
| 224 | cbi portb, 0 ;signal auf low ziehen
| 225 | sbi ddrb,0 ;pb0 ausgang
| 226 | rcall wait6us ;und 6us halten
| 227 |
| 228 | cbi ddrb, 0 ;lässt bus los
| 229 | rcall wait9us ;wartet dazu 9us
| 230 |
| 231 | sbis pinb,0 ;prüfen ob null anliegt
| 232 | rjmp read_bit2 ;wenn 0 dann springen
| 233 |
| 234 | ldi temp2, 128 ;10000000 laden
| 235 | add temp3, temp2 ;und zu temp3 addieren
| 236 |
| 237 | read_bit2:
| 238 |
| 239 | rcall wait55us ;wartet 55us
| 240 | dec temp1 ;temp1 erniedigen
| 241 | brne read_bit1 ;von vorne bis temp1=0
| 242 |
| 243 | ret
| 244 |
| 245 |
| 246 | ;-----------------------------------------------------------------------------
| 247 |
| 248 |
| 249 | write_command:
| 250 |
| 251 | ldi temp1, 8 ; für 8 mal durchführen (8bit)
| 252 |
| 253 | write_command1:
| 254 |
| 255 | sbrs r10, 0 ;prüfen ob 0
| 256 | rcall write_0 ;wenn ja dann 0 schreiben
| 257 |
| 258 | sbrc r10, 0 ;prüfen ob 1
| 259 | rcall write_1 ;wenn ja dann 1 schreiben
| 260 |
| 261 | ror r10 ;rollen
| 262 | dec temp1 ;um eins erniedrigen
| 263 | brne write_command1 ;von vorne bis temp1=0
| 264 |
| 265 | ret
| 266 |
| 267 | ;-----------------------------------------------------------------------------
| 268 |
| 269 |
| 270 | skip_rom:
| 271 |
| 272 | ldi temp1, 0xCC ;befehl für skip rom
| 273 | mov r10, temp1
| 274 | rcall write_command ;schicken
| 275 | ret
| 276 |
| 277 | ;-----------------------------------------------------------------------------
| 278 |
| 279 |
| 280 | convert_t:
| 281 |
| 282 | ldi temp1, 0x44 ;befehl für convert_t
| 283 | mov r10, temp1
| 284 | rcall write_command ;schicken
| 285 |
| 286 | rcall wait60us
| 287 |
| 288 | convert_t1:
| 289 | rcall wait70us
| 290 | sbis pinb,0
| 291 | rjmp convert_t1
| 292 |
| 293 |
| 294 | ret
| 295 |
| 296 |
| 297 | ;-----------------------------------------------------------------------------
| 298 |
| 299 |
| 300 | read_scratchpad:
| 301 |
| 302 | ldi temp1, 0xBE ;befehl für scratchpad
| 303 | mov r10, temp1
| 304 | rcall write_command ;schicken
| 305 |
| 306 |
| 307 | rcall read_bit ;einlesen und speichern
| 308 | sts temp_lsb, temp3
| 309 |
| 310 | rcall read_bit
| 311 | sts temp_msb, temp3
| 312 |
| 313 | rcall read_bit
| 314 | sts th_reg, temp3
| 315 |
| 316 | rcall read_bit
| 317 | sts tl_reg, temp3
| 318 |
| 319 | rcall read_bit
| 320 | sts res1, temp3
| 321 |
| 322 | rcall read_bit
| 323 | sts res2, temp3
| 324 |
| 325 | rcall read_bit
| 326 | sts count_re, temp3
| 327 |
| 328 | rcall read_bit
| 329 | sts count_pc, temp3
| 330 |
| 331 | rcall read_bit
| 332 | sts crc, temp3
| 333 |
| 334 | ret
| 335 |
| 336 |
| 337 |
| 338 | ;-----------------------------------------------------------------------------
| 339 |
| 340 |
| 341 | wait500us:
| 342 | ldi loop1, 200
| 343 | ldi loop2, 6
| 344 | wait500us1:
| 345 |
| 346 | inc loop1
| 347 | brne wait500us1
| 348 | dec loop2
| 349 | brne wait500us1
| 350 |
| 351 | ret
| 352 |
| 353 |
| 354 | ;-----------------------------------------------------------------------------
| 355 |
| 356 |
| 357 | wait410us:
| 358 | ldi loop1, 5
| 359 | ldi loop2, 185
| 360 | wait410us2:
| 361 | inc loop1
| 362 | brne wait410us2
| 363 | dec loop2
| 364 | brne wait410us2
| 365 |
| 366 | ret
| 367 |
| 368 |
| 369 | ;-----------------------------------------------------------------------------
| 370 |
| 371 |
| 372 | wait70us:
| 373 | ldi loop1, 185
| 374 | wait70us1:
| 375 | inc loop1
| 376 | brne wait70us1
| 377 |
| 378 |
| 379 | ret
| 380 |
| 381 |
| 382 | ;-----------------------------------------------------------------------------
| 383 |
| 384 |
| 385 | wait65us:
| 386 | ldi loop1, $AD
| 387 | wait65us1:
| 388 | dec loop1
| 389 | brne wait65us1
| 390 | nop
| 391 |
| 392 | ret
| 393 |
| 394 |
| 395 | ;-----------------------------------------------------------------------------
| 396 |
| 397 |
| 398 | wait60us:
| 399 | ldi loop1, $A0
| 400 | wait60us1:
| 401 | dec loop1
| 402 | brne wait60us1
| 403 |
| 404 | ret
| 405 |
| 406 |
| 407 | ;-----------------------------------------------------------------------------
| 408 |
| 409 |
| 410 | wait55us:
| 411 | ldi loop1, $92
| 412 | wait55us1:
| 413 | dec loop1
| 414 | brne wait55us1
| 415 | nop
| 416 | nop
| 417 |
| 418 | ret
| 419 |
| 420 |
| 421 | ;-----------------------------------------------------------------------------
| 422 |
| 423 |
| 424 | wait10us:
| 425 | ldi loop1, $1A
| 426 | wait10us1:
| 427 | dec loop1
| 428 | brne wait10us1
| 429 | nop
| 430 | nop
| 431 |
| 432 | ret
| 433 |
| 434 |
| 435 | ;-----------------------------------------------------------------------------
| 436 |
| 437 |
| 438 | wait9us:
| 439 | ldi loop1, $18
| 440 | wait9us1:
| 441 | dec loop1
| 442 | brne wait9us1
| 443 |
| 444 | ret
| 445 |
| 446 |
| 447 | ;-----------------------------------------------------------------------------
| 448 |
| 449 |
| 450 | wait6us:
| 451 | ldi loop1, $10
| 452 | wait6us1:
| 453 | dec loop1
| 454 | brne wait6us1
| 455 |
| 456 | ret
| 457 |
| 458 |
| 459 |
| 460 | .include "sekunden-routine.asm"
| 461 | .include "LCD-Routine PortC.asm"
| 462 | .include "BIN2ASCII 16Bit.asm"
|
|