[Menu]>[Circuits Gallery]>[Remote display]
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 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 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | ;******************************************************** ; ; Remote display ; ; Device : PIC16F873 ; Author : Seiichi Inoue ;******************************************************** list p=pic16f873 include p16f873.inc __config _hs_osc & _wdt_off & _pwrte_on & _lvp_off errorlevel -302 ;Suppress bank warning ;**************** Label Definition ******************** cblock h'20' data_c ;Category data data_h ;100th digit data data_t ;10th digit data data_u ;1st digit data disp_p ;LED position key_p ;Key position key_data ;Key data key_flag ;Key flag tx_p ;Send position endc rc4 equ h'04' ;RC4 port designation seg7_0 equ b'00000001' ;-abcdefg Pattern 0 seg7_1 equ b'01001111' ; Pattern 1 seg7_2 equ b'00010010' ; Pattern 2 seg7_3 equ b'00000110' ; Pattern 3 seg7_4 equ b'01001100' ; Pattern 4 seg7_5 equ b'00100100' ; Pattern 5 seg7_6 equ b'00100000' ; Pattern 6 seg7_7 equ b'00001111' ; Pattern 7 seg7_8 equ b'00000000' ; Pattern 8 seg7_9 equ b'00000100' ; Pattern 9 seg7_a equ b'00110000' ; Illegal int seg7_b equ b'01111111' ; LED off ;**************** Program Start *********************** org 0 ;Reset Vector goto init org 4 ;Interrupt Vector goto int ;**************** Initial Process ********************* init ;*** Port mode initializing bsf status,rp0 ;Change to Bank1 movlw b'00000110' ;RA port to digital mode movwf adcon1 ;Set ADCON1 register clrf trisa ;Set RA to output mode clrf trisb ;Set RB to output mode movlw b'00010000' ;RC4 input, other output movwf trisc ;Set TRISC register ;*** LED & KEY scan interval initializing (Timer0 = 2ms) movlw b'10000010' ;PBPU=off,PSA=0,PS=1:8 movwf option_reg ;Set OPTION_REG register bcf status,rp0 ;Change to Bank0 movlw d'6' ;(256-6)x8=2000usec movwf tmr0 ;Set TMR0 register ;*** Port initializing movlw b'00001110' ;Set TR1 = ON movwf porta ;Write PORTA movlw b'01111111' ;Set LED off data movwf portb ;Write PORTB clrf portc ;Write SW1 select data ;*** Work area initializing movlw b'01111111' ;Set Category LED off movwf data_c ;Set Category LED data movlw seg7_b ;Set 7segment pattern B movwf data_h ;Set 100th LED off data movwf data_t ;Set 10th LED off data movwf data_u ;Set 1st LED off data movlw d'4' ;LED position = 4 movwf disp_p ;Set LED position data movlw d'15' ;Key position = 15 movwf key_p ;Set Key position data clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag movlw d'6' ;Send position = 6 movwf tx_p ;Set Send position data ;*** USART control bsf status,rp0 ;Change to Bank1 movlw d'25' ;Speed = 9600bps movwf spbrg ;Set SPBRG register bcf txsta,sync ;Set Async mode bsf txsta,brgh ;Set BRGH(High-speed) bcf txsta,txen ;Set Send disenable bsf pie1,txie ;Set TX interruption bcf status,rp0 ;Change to Bank0 bsf rcsta,spen ;Set Serial-port ;*** Interruption control movlw b'11100000' ;GIE,PEIE,T0IE = ON movwf intcon ;Set INTCON register wait goto $ ;wait ;*************** Interruption Process ***************** int btfsc intcon,t0if ;Check TMR0 goto led ;TMR0 time-out btfsc pir1,txif ;Check TX buffer goto send_data ;TX buffer is empty ;******** Illegal interruption (For debugging) ******** illegal movlw seg7_a ;Set 7segment pattern A movwf portb ;Write LED data movlw b'00000111' ;Set 1st digit select movwf porta ;Write LED select data goto $ ;Stop ;************ END of Interruption Process ************** int_end retfie ;**************** LED control Process ***************** led bcf intcon,t0if ;Clear T0IF movlw d'6' ;Set Time value (2msec) movwf tmr0 ;Write TMR0 register movlw d'4' ;Set check data subwf disp_p,w ;Check LED position data btfss status,z ;Position = 4 ? goto led1 ;No. movlw b'00001110' ;Set TR1 = ON movwf porta ;Write LED select data movfw data_c ;Read Category data goto led_cont ;Jump to LED control led1 movlw d'3' ;Set check data subwf disp_p,w ;Check LED position data btfss status,z ;Position = 3 ? goto led2 ;No. movlw b'00001101' ;Set TR2 = ON movwf porta ;Write LED select data movfw data_h ;Read 100th digit data goto led_cont ;Jump to LED control led2 movlw d'2' ;Set check data subwf disp_p,w ;Check LED position data btfss status,z ;Position = 2 ? goto led3 ;No. movlw b'00001011' ;Set TR3 = ON movwf porta ;Write LED select data movfw data_t ;Read 10th digit data goto led_cont ;Jump to LED control led3 movlw d'1' ;Set check data subwf disp_p,w ;Check LED position data btfss status,z ;Position = 1 ? goto led4 ;No. movlw b'00000111' ;Set TR4 = ON movwf porta ;Write LED select data movfw data_u ;Read 1st digit data led_cont movwf portb ;Write LED control data decfsz disp_p,f ;LED position data - 1 goto key ;Jump to key scan led4 movlw d'4' ;Set LED position data movwf disp_p ;Write LED position data ;****************** Key scan Process ****************** key ;**** Check SW1 (Digit 1) movlw d'15' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 15 ? goto key2 ;No. movlw b'00000000' ;Set SW1 select data movwf portc ;Write SW1 select data btfsc portc,rc4 ;SW1 = ON ? goto key1_1 ;No. movlw d'1' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key1_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key1_3 ;No. goto key_end1 ;Jump to SW1 scan key1_1 movlw d'1' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key1_2 movlw d'1' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key1_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_1 ;Set 7segment pattern 1 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW2 (Digit 2) key2 movlw d'14' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 14 ? goto key3 ;No. movlw b'00000001' ;Set SW2 select data movwf portc ;Write SW2 select data btfsc portc,rc4 ;SW2 = ON ? goto key2_1 ;No. movlw d'2' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key2_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key2_3 ;No. goto key_end1 ;Jump to SW1 scan key2_1 movlw d'2' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key2_2 movlw d'2' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key2_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_2 ;Set 7segment pattern 2 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW3 (Digit 3) key3 movlw d'13' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 13 ? goto key4 ;No. movlw b'00000010' ;Set SW3 select data movwf portc ;Write SW3 select data btfsc portc,rc4 ;SW3 = ON ? goto key3_1 ;No. movlw d'3' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key3_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key3_3 ;No. goto key_end1 ;Jump to SW1 scan key3_1 movlw d'3' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key3_2 movlw d'3' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key3_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_3 ;Set 7segment pattern 3 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW4 (Digit 4) key4 movlw d'12' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 12 ? goto key5 ;No. movlw b'00000011' ;Set SW4 select data movwf portc ;Write SW4 select data btfsc portc,rc4 ;SW4 = ON ? goto key4_1 ;No. movlw d'4' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key4_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key4_3 ;No. goto key_end1 ;Jump to SW1 scan key4_1 movlw d'4' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key4_2 movlw d'4' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key4_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_4 ;Set 7segment pattern 4 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW5 (Digit 5) key5 movlw d'11' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 11 ? goto key6 ;No. movlw b'00000100' ;Set SW5 select data movwf portc ;Write SW5 select data btfsc portc,rc4 ;SW5 = ON ? goto key5_1 ;No. movlw d'5' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key5_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key5_3 ;No. goto key_end1 ;Jump to SW1 scan key5_1 movlw d'5' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key5_2 movlw d'5' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key5_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_5 ;Set 7segment pattern 5 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW6 (Digit 6) key6 movlw d'10' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 10 ? goto key7 ;No. movlw b'00000101' ;Set SW6 select data movwf portc ;Write SW6 select data btfsc portc,rc4 ;SW6 = ON ? goto key6_1 ;No. movlw d'6' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key6_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key6_3 ;No. goto key_end1 ;Jump to SW1 scan key6_1 movlw d'6' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key6_2 movlw d'6' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key6_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_6 ;Set 7segment pattern 6 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW7 (Digit 7) key7 movlw d'9' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 9 ? goto key8 ;No. movlw b'00000110' ;Set SW7 select data movwf portc ;Write SW7 select data btfsc portc,rc4 ;SW7 = ON ? goto key7_1 ;No. movlw d'7' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key7_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key7_3 ;No. goto key_end1 ;Jump to SW1 scan key7_1 movlw d'7' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key7_2 movlw d'7' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key7_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_7 ;Set 7segment pattern 7 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW8 (Digit 8) key8 movlw d'8' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 8 ? goto key9 ;No. movlw b'00000111' ;Set SW8 select data movwf portc ;Write SW8 select data btfsc portc,rc4 ;SW8 = ON ? goto key8_1 ;No. movlw d'8' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key8_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key8_3 ;No. goto key_end1 ;Jump to SW1 scan key8_1 movlw d'8' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key8_2 movlw d'8' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key8_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_8 ;Set 7segment pattern 8 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW9 (Digit 9) key9 movlw d'7' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 7 ? goto key10 ;No. movlw b'00001000' ;Set SW9 select data movwf portc ;Write SW9 select data btfsc portc,rc4 ;SW9 = ON ? goto key9_1 ;No. movlw d'9' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key9_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key9_3 ;No. goto key_end1 ;Jump to SW1 scan key9_1 movlw d'9' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key9_2 movlw d'9' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key9_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_9 ;Set 7segment pattern 9 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW10 (Digit 0) key10 movlw d'6' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 6 ? goto key11 ;No. movlw b'00001001' ;Set SW10 select data movwf portc ;Write SW10 select data btfsc portc,rc4 ;SW10 = ON ? goto key10_1 ;No. movlw d'10' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key10_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key10_3 ;No. goto key_end1 ;Jump to SW1 scan key10_1 movlw d'10' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key10_2 movlw d'10' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key10_3 bsf key_flag,0 ;Set Key flag movfw data_t ;Read 10th digit movwf data_h ;Set 100th digit movfw data_u ;Read 1st digit movwf data_t ;Set 10th digit movlw seg7_0 ;Set 7segment pattern 0 movwf data_u ;Set 1st digit goto key_end1 ;Jump to SW1 scan ;**** Check SW11 (Category 1(Sei)) key11 movlw d'5' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 5 ? goto key12 ;No. movlw b'00001010' ;Set SW11 select data movwf portc ;Write SW11 select data btfsc portc,rc4 ;SW11 = ON ? goto key11_1 ;No. movlw d'11' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key11_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key11_3 ;No. goto key_end1 ;Jump to SW1 scan key11_1 movlw d'11' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key11_2 movlw d'11' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key11_3 bsf key_flag,0 ;Set Key flag movlw b'00111111' ;Set Category 1(Sei) movwf data_c ;Set Category data goto key_end1 ;Jump to SW1 scan ;**** Check SW12 (Category 2(Ten)) key12 movlw d'4' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 4 ? goto key13 ;No. movlw b'00001011' ;Set SW12 select data movwf portc ;Write SW12 select data btfsc portc,rc4 ;SW12 = ON ? goto key12_1 ;No. movlw d'12' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key12_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key12_3 ;No. goto key_end1 ;Jump to SW1 scan key12_1 movlw d'12' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key12_2 movlw d'12' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key12_3 bsf key_flag,0 ;Set Key flag movlw b'01011111' ;Set Category 2(Ten) movwf data_c ;Set Category data goto key_end1 ;Jump to SW1 scan ;**** Check SW13 (Category 3(Pu)) key13 movlw d'3' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 3 ? goto key14 ;No. movlw b'00001100' ;Set SW13 select data movwf portc ;Write SW13 select data btfsc portc,rc4 ;SW13 = ON ? goto key13_1 ;No. movlw d'13' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key13_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key13_3 ;No. goto key_end1 ;Jump to SW1 scan key13_1 movlw d'13' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key13_2 movlw d'13' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key13_3 bsf key_flag,0 ;Set Key flag movlw b'01101111' ;Set Category 3(Pu) movwf data_c ;Set Category data goto key_end1 ;Jump to SW1 scan ;**** Check SW14 (Send) key14 movlw d'2' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 2 ? goto key15 ;No. movlw b'00001101' ;Set SW14 select data movwf portc ;Write SW14 select data btfsc portc,rc4 ;SW14 = ON ? goto key14_1 ;No. movlw d'14' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key14_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key14_3 ;No. goto key_end1 ;Jump to SW1 scan key14_1 movlw d'14' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end ;Jump to Key scan end key14_2 movlw d'14' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key14_3 bsf key_flag,0 ;Set Key flag bsf status,rp0 ;Change to Bank1 bsf txsta,txen ;Set Send enable bcf status,rp0 ;Change to Bank0 goto key_end1 ;Jump to SW1 scan ;**** Check SW15 (Clear) key15 movlw d'1' ;Set check data subwf key_p,w ;Check Key position data btfss status,z ;Position = 1 ? goto key_end1 ;Jump to SW1 scan movlw b'00001110' ;Set SW15 select data movwf portc ;Write SW15 select data btfsc portc,rc4 ;SW15 = ON ? goto key15_1 ;No. movlw d'15' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;2nd time ? goto key15_2 ;No. btfss key_flag,0 ;Key flag ON ? goto key15_3 ;No. goto key_end1 ;Jump to SW1 scan key15_1 movlw d'15' ;Set check data subwf key_data,w ;Check Key data btfss status,z ;Corresponding key off ? goto key_end1 ;No. clrf key_data ;Clear Key data clrf key_flag ;Clear Key flag goto key_end1 ;Jump to Key scan end key15_2 movlw d'15' ;Set key data movwf key_data ;Save key data goto key_end1 ;Jump to SW1 scan key15_3 bsf key_flag,0 ;Set Key flag movlw b'01111111' ;Set Category LED off movwf data_c ;Set Category LED data movlw seg7_b ;Set 7segment pattern B movwf data_h ;Set 100th LED off data movwf data_t ;Set 10th LED off data movwf data_u ;Set 1st LED off data goto key_end1 ;Jump to SW1 scan key_end decfsz key_p,f ;Key position data - 1 goto int_end ;Jump to END of interrupt key_end1 movlw d'15' ;Set Key position data movwf key_p ;Write Key position data goto int_end ;Jump to END of interrupt ;***************** Data send Process ****************** send_data ;**** Send Start data movlw d'6' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;Category data ? goto send1 ;No. movlw b'10000000' ;Set Start data movwf txreg ;Write Start data goto send_end ;Jump to Send end send1 ;**** Send Category data movlw d'5' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;Category data ? goto send2 ;No. movfw data_c ;Read Category data movwf txreg ;Write Category data goto send_end ;Jump to Send end send2 ;**** Send 100th data movlw d'4' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;100th data ? goto send3 ;No. movfw data_h ;Read 100th data movwf txreg ;Write 100th data goto send_end ;Jump to Send end ;**** Send 10th data send3 movlw d'3' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;10th data ? goto send4 ;No. movfw data_t ;Read 10th data movwf txreg ;Write 10th data goto send_end ;Jump to Send end ;**** Send 1st data send4 movlw d'2' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;1st data ? goto send5 ;No. movfw data_u ;Read 1st data movwf txreg ;Write 1st data goto send_end ;Jump to Send end ;**** Stop transmission send5 movlw d'1' ;Set check data subwf tx_p,w ;Check send position btfss status,z ;Stop transmission ? goto send_end1 ;No. bsf status,rp0 ;Change to Bank1 tx_wait btfss txsta,trmt ;TX end ? goto tx_wait ;No. bcf txsta,txen ;Set Send disenable bcf status,rp0 ;Change to Bank0 send_end decfsz tx_p,f ;Send position - 1 goto int_end ;Jump to END of interrupt send_end1 movlw d'6' ;Set Send position data movwf tx_p ;Write Send position data goto int_end ;Jump to END of interrupt end |
r_disp_source.zip r_disp_hex.zip |