tailieunhanh - NIGEL PIC Tutorial Hardware phần 9

Tải tập tin hướng dẫn nén. IR truyền có những hạn chế, điều quan trọng nhất (cho các mục đích của chúng tôi) là người nhận không đưa ra các xung chiều rộng tương tự mà chúng tôi truyền tải, vì vậy chúng ta có thể không chỉ sử dụng một loại bình thường, RS232, nối tiếp dòng dữ liệu, Thay vì hiển thị các thói quen trên các trang như là với các hướng dẫn trước đó (chúng được | Ser_Out Equ 0x01 Ser_In Equ 0x02 SW1 Equ 7 set constants for the switches SW2 Equ 6 SW3 Equ 5 SW4 Equ 4 TV_ID Equ 0x01 TV device ID Butl Equ 0x00 numeric button ID s But2 Equ 0x01 But3 Equ 0x02 But4 Equ 0x03 But5 Equ 0x04 But6 Equ 0x05 But7 Equ 0x06 But8 Equ 0x07 But9 Equ 0x08 ProgUp Equ d 16 ProgDn Equ d 17 VolUp Equ d 18 VolD n Equ d 19 org 0x0000 org sets the origin 0x0000 for the 16F628 goto Start this is where the program starts running org 0x005 Start movlw 0x07 movwf CMCON turn comparato rs off make it like a 16F84 clrf IR_PORT make PortB output s low bsf STATUS RP0 select bank 1 movlw b 11111101 set PortB all inputs except RB1 movwf IR_TRIS movlw 0xff movwf PORTA bcf STATUS RP0 select bank 0 Read_Sw btf ss PORTA SW1 call Switch1 btf ss PORTA SW2 call Switch2 btf ss PORTA SW3 call Switch3 btf ss PORTA SW4 call Switch4 call Delay27 goto Read_Sw Switch1 movlw ProgUp call Xmit_RS232 retlw 0x00 Switch2 Switch3 Switch4 TX_Start TX_One TX_Zero IR_pulse irloop movlw ProgDn call Xmit_RS232 retlw 0x00 movlw call retlw VolUp Xmit_RS232 0x00 movlw VolDn call Xmit_RS232 retlw 0x00 movlw d 92 call IR_pulse movlw d 2 3 call NO_pulse retlw 0x00 movlw d 46 call IR_pulse movlw d 23 call NO_pulse retlw 0x00 movlw d 23 call IR_pulse movlw d 23 call NO_pulse retlw 0x00 NO_pulse irloop2 MOVWF count Pulses the IR led at 3 8KHz BSF IR_PORT IR_Out NOP NOP NOP NOP NOP NOP NOP BCF IR_PORT IR_Out NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP DECFSZ count F GOTO irloop RETLW 0 MOVWF count Doesn t pulse the IR led BCF IR_PORT IR_Out NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP BCF IR_PORT IR_Out NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP DECFSZ count F GOTO irloop2 RETLW 0 Xmit _RS232 MOVWF Data_Byte -move W to Data_Byte MOVLW 0x07- -set 7 DATA bits out MOVWF Bit_Cntr call TX_Start -send start bit Ser_ Loop RRF Data_Byte f -send one bit BTFSC STATUS C call TX_One BTFSS STATUS C call TX_Zero DECFSZ Bit_Cntr f -test if all done GOTO Ser_Loop -now send device data movlw D 1 movwf .

TỪ KHÓA LIÊN QUAN