Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 ; ‚ ; ; PIC 16F630 ; ;--------------------------------------------------------------------- ; ; MPASM ‚ ; ; ; ; ; .osc hs ; .pwrt on ; .wdt off ; .protect off ; ;--------------------------------------------------------------------- P=16F630 #include <P16F630.INC> __config _WDT_OFF & _XT_OSC & _CP_OFF & _MCLRE_OFF & _PWRTE_ON ;#################################################### #define pilamp 5e,0 ; # #define irdin 5e,1 ; # #define memsw 5e,2 ; # ;#################################################### ;#################################################### rbytes equ 6 ind0 equ 20 status equ 21 fsr equ 22 porta equ 5e portc equ 24 datatop equ 25 ;#################################################### ird1 equ 25 ird2 equ 26 ird3 equ 28 ird4 equ 2c ird5 equ 2d ird6 equ 2e ird7 equ 2f ird8 equ 30 flg equ 31 ;#################################################### ;#################################################### bitlc equ 32 pwf equ 33 pwr equ 34 pw1 equ 35 eepa equ 36 ;EEPROM poi equ 37 ;EEPROM keyss equ 38 syflg equ 39 memc equ 3A mflg equ 3C ;#################################################### ;#################################################### s1 equ 3e s2 equ 3f s3 equ 40 s4 equ 41 lc1 equ 42 lc2 equ 43 lc3 equ 44 ;#################################################### org 0 goto start org 4 goto start ;********************************************************************* start bsf STATUS,RP0 movlw b'0110' movwf 05e movlw b'000000' movwf 24 movlw b'111111' movwf 4d clrf 4A bcf STATUS,RP0 clrf 4f bsf pilamp clrf flg clrf mflg clrf syflg clrf portc ;********************************************************************* m10 btfss memsw goto m13 btfss irdin goto m11 goto m10 m11 btfsc irdin goto m10 call wait20 btfsc irdin goto m10 call wait20 btfsc irdin goto m10 m12 call irrecive call check goto m10 m13 call kmemory goto m10 ;********************************************************************* epread ;EEPROM movf poi,0 movwf 4b ;EEPROM bsf 3,5 bsf 4,0 bcf 3,5 movf 4,0 ;EEPROM return ;********************************************************************* epwrite ;EEPROM movwf 4h movf poi,0 movwf 4b bsf 3h,5 bsf 4h,2 ;EEPROM movlw 55h movwf 4b movlw 0aah movwf 4b bsf 4h,1 epr01 btfsc 4h,1 goto epr01 bcf 4h,4 bcf 4h,2 ;EEPROM bcf 3h,5 return ;********************************************************************* kmemory ;keyss EEPROM call swait btfsc memsw goto km30 call swait btfsc memsw goto km30 call swait btfsc memsw goto km30 movlw 6h movwf keyss clrf eepa ;EEPROM km10 movf eepa,0 movwf poi ;EEPROM bcf pilamp km11 btfsc irdin goto km11 call wait20 btfsc irdin goto km11 call wait20 btfsc irdin goto km11 call irrecive call memory movlw 5e call pdblink1 movlw rbytes addwf eepa,1 ;EEPROM decfsz keyss,1 goto km10 km30 return ;********************************************************************* memory ;poi movlw rbytes movwf memc movlw datatop movwf fsr mmw10 movf ind0,0 call epwrite ;EEPROM incf poi,1 incf fsr,1 decfsz memc,1 goto mmw10 return ;********************************************************************* check bcf flg,1 bcf flg,2 bcf mflg,0 clrf eepa ;EEPROM clrf poi ;EEPROM cck00 call keycheck btfsc flg,3 goto cck000 cck10 call keycheck btfsc flg,3 goto cck100 ;rc1 cck11 call keycheck btfsc flg,3 goto cck200 ;rc2 cck12 call keycheck btfsc flg,3 goto cck300 ;rc3 cck13 call keycheck btfsc flg,3 goto cck400 ;rc4 cck14 call keycheck btfsc flg,3 goto cck500 ;rc5 cck15 call keycheck btfsc flg,3 goto cck600 ;rc6 cck16 call keycheck btfsc flg,3 goto cck700 ;rc7 goto cck30 ;########################################################### cck000 ;rc0 cck005 bsf flg,2 btfsc syflg,0 goto cck006 bsf portc,0 bsf syflg,0 goto cck10 cck006 bcf portc,0 bcf syflg,0 goto cck10 ;---------- cck100 ;rc1 cck105 bsf flg,2 btfsc syflg,1 goto cck106 bsf portc,1 bsf syflg,1 goto cck11 cck106 bcf portc,1 bcf syflg,1 goto cck11 ;---------- cck200 ;rc2 cck205 bsf flg,2 btfsc syflg,2 goto cck206 bsf portc,2 bsf syflg,2 goto cck12 cck206 bcf portc,2 bcf syflg,2 goto cck12 ;---------- cck300 ;rc3 cck305 bsf flg,2 btfsc syflg,3 goto cck306 bsf portc,3 bsf syflg,3 goto cck13 cck306 bcf portc,3 bcf syflg,3 goto cck13 ;---------- cck400 ;rc4 cck405 bsf flg,2 btfsc syflg,4 goto cck406 bsf portc,4 bsf syflg,4 goto cck14 cck406 bcf portc,4 bcf syflg,4 goto cck14 ;---------- cck500 ;rc5 cck505 bsf flg,2 btfsc syflg,5 goto cck506 bsf portc,5 bsf syflg,5 goto cck15 cck506 bcf portc,5 bcf syflg,5 goto cck15 ;---------- cck600 ;rc6 bsf flg,2 btfsc syflg,6 goto cck601 bsf portc,6 bsf syflg,6 goto cck16 cck601 bcf portc,6 bcf syflg,6 goto cck16 ;---------- cck700 ;rc7 bsf flg,2 btfsc syflg,7 goto cck701 bsf portc,7 bsf syflg,7 goto cck30 cck701 bcf portc,7 bcf syflg,7 ;############################################################### cck30 bcf mflg,3 btfsc flg,2 goto cck32 cck33 btfsc flg,1 goto cck31 return cck31 btfsc mflg,3 goto cck34 cck35 call dcontchk btfsc flg,6 goto cck35 cck34 bcf portc,0 bcf portc,1 bcf portc,2 bcf portc,3 btfss mflg,0 goto cck36 cck36 return cck32 bsf mflg,3 call dcontchk btfsc flg,6 goto cck32 goto cck33 ;********************************************************************* dcontchk ;150(50)mS bcf flg,6 movlw 0dh ; movlw 27h movwf lc2 dtc30 clrf lc3 dtc50 btfss irdin goto dtc70 dtc51 call wait10 decfsz lc3,1 goto dtc50 decfsz lc2,1 goto dtc30 return dtc70 nop btfsc irdin goto dtc51 nop btfsc irdin goto dtc51 nop btfsc irdin goto dtc51 bsf flg,6 return ;********************************************************************* keycheck movlw rbytes movwf lc1 movlw datatop movwf fsr dchk10 call epread ;EEPROM subwf ind0,0 btfss status,2 goto dchk12 incf poi,1 incf fsr,1 decfsz lc1,1 goto dchk10 bsf flg,3 goto dchk13 dchk12 bcf flg,3 dchk13 movlw rbytes addwf eepa,1 movf eepa,0 movwf poi return ;********************************************************************* irrecive irr10 bcf flg,5 movlw rbytes*8 movwf bitlc irr24 call p1wide2 rlf ird1,1 rlf ird2,1 rlf ird3,1 rlf ird4,1 rlf ird5,1 rlf ird6,1 rlf ird7,1 rlf ird8,1 btfsc flg,5 goto irr25 btfsc flg,4 bsf flg,5 irr27 decfsz bitlc,1 ; (rbitlgs) goto irr24 return irr25 decf bitlc,1 irr26 bcf status,0 rlf ird1,1 rlf ird2,1 rlf ird3,1 rlf ird4,1 rlf ird5,1 rlf ird6,1 rlf ird7,1 rlf ird8,1 decfsz bitlc,1 ; (rbitlgs) goto irr26 return ;********************************************************************* p1wide2 clrf pw1 bcf flg,4 bcf flg,7 movlw 4h movwf lc2 p2w10 clrf lc3 p2w11 btfsc irdin goto p2w13 nop nop nop p2w16 nop nop p2w12 decfsz lc3,1 goto p2w11 bsf flg,7 decfsz lc2,1 goto p2w10 goto p2w14 p2w13 btfss irdin goto p2w16 call wait05 btfss irdin goto p2w12 clrf pwf movf lc3,0 subwf pwf,1 goto p2w15 p2w14 movlw 0ffh ;ffh=255 movwf pw1 bsf flg,4 p2w15 ;-------------------- movlw 4h ;‚P’Pˆت‚¨ movwf lc2 p2w20 clrf lc3 p2w21 btfss irdin goto p2w23 nop nop nop p2w31 nop nop p2w22 decfsz lc3,1 goto p2w21 bsf flg,7 decfsz lc2,1 goto p2w20 goto p2w30 p2w23 btfsc irdin goto p2w31 call wait05 btfsc irdin goto p2w22 clrf pwr movf lc3,0 subwf pwr,1 ;-------------------- p2w27 movf pwr,0 addwf pwf,0 movwf pw1 btfsc 3h,0 goto p2w28 movlw 8ch ;8ch=140 subwf pw1,0 p2w28 return p2w30 movlw 0ffh ;ffh=255 movwf pw1 bsf flg,4 bsf status,0 return ;********************************************************************* wait200 movlw 41h movwf s1 w210 decfsz s1,1 goto w210 return ;********************************************************************* wait20 nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop return ;********************************************************************* wait10 nop nop nop nop nop nop return ;********************************************************************* wait05 nop return ;********************************************************************* pdblink3 movwf lc1 pdbl310 bsf portc,0 call wait41 bcf portc,0 call wait41 decfsz lc1,1 goto pdbl310 return ;********************************************************************* pdblink1 movwf lc1 pdbl110 bcf pilamp call wait41 bsf pilamp call wait41 decfsz lc1,1 goto pdbl110 return ;********************************************************************* wait41 ; 4MHz ;-------------------- movlw 0f8h movwf s3 w403 movlw 4h ;250ƒتS*4=1mS movwf s2 w402 movlw 3eh ;3eh=62 62*4=248ƒتS movwf s1 w401 nop decfsz s1,1 goto w401 ;250ƒتS decfsz s2,1 goto w402 ;1mS decfsz s3,1 goto w403 ;250mS return ;********************************************************************* swait ;-------------------- clrf s1 swait0 movlw 0ah ;0ah=10 movwf s2 swait1 nop decfsz s2,1 goto swait1 decfsz s1,1 goto swait0 return ;********************************************************************* end