Conversation Between TANDEM and thanhphongsmail
		
		
	
		
		Showing Visitor Messages 1 to 1 of 1
	
	
	
		- 
	
		
	 
	
		
		
		em có làm 2 pic16f877a master và slave điều khiển hai led qua hai nút nhấn(button). 
nhưng sao em cứ làm mãi mà vẫn không được,mong mấy anh giúp đỡ, em cảm ơn.
;==========================================
; BUI THANH PHONG _LOP 08CDCK1 _ 3003080048
;==========================================
list p=16F877A
#include "p16F877a.inc"
Ctr0    EQU 0x20            ;  
Dly0    EQU 0x21            ; 
Dly1    EQU 0x22            ; 
#define CS  0x02            ; 
		ORG 0               ; 
		nop                 ; 
; Set up the SPI Support
		BANKSEL TRISA       ; BANK 1
		movlw   0x00        ;  
		movwf   TRISA       ;  
		movlw   0x06        ;   
		movwf   ADCON1      ;   
; Set up the SPI Port
		BANKSEL TRISC       ; BANK 1
		movlw   0x10        ;   
		movwf   TRISC       ;  
		movlw   0x40        ;  
		movwf   SSPSTAT     ;  
		BANKSEL SSPCON      ; BANK 0
		movlw   0x31        ; 
		movwf   SSPCON      ; 
Send_DT bcf     PORTA,CS    ; 
		BTFSC	PORTA,0		;
		GOTO	Send_DT		;
		movlw    b'00000011'           ;
sw0	
		btfsc	PORTA,0		;
		goto	turnon0		;
		bcf	PORTB,0		;
		goto	sw0		;
turnon0	             bsf	PORTB,0		;
		goto	sw0		;
sw1	
		btfsc	PORTA,1		;
		goto	turnon0		;
		bcf	PORTB,1		;
		goto	sw1		;
turnon1	             bsf	PORTB,1		;
		goto	sw1		;
	
	 	movwf   SSPBUF      ;
		BANKSEL SSPSTAT     ; BANK 1
Char1                  btfss   SSPSTAT,BF  ; 
		goto    Char1       ;  
		BANKSEL SSPBUF      ; 
		movf    SSPBUF,W    ; 
;               			; 
		bsf     PORTA,CS    ; 
Update_Test_Counter
		incf    Ctr0,F      ; 
Delay   movlw   0x01        ; 
		movwf   Dly1        ;         
		movlw   0x0F        ;         
		movwf   Dly0        ;         
DlyLoop decfsz  Dly0,F      ;         
		goto    DlyLoop     ;         
		decfsz  Dly1,F      ;         
		goto    DlyLoop     ;         
; Done Delay        ;       
DoAgain goto    Send_DT     ; 
		end
và nan giải nhất là phần này nè:
Send_DT bcf     PORTA,CS    ; 
		BTFSC	PORTA,0		;
		GOTO	Send_DT		;
		movlw    b'00000011'           ;
sw0	
		btfsc	PORTA,0		;
		goto	turnon0		;
		bcf	PORTB,0		;
		goto	sw0		;
turnon0	             bsf	PORTB,0		;
		goto	sw0		;
sw1	
		btfsc	PORTA,1		;
		goto	turnon0		;
		bcf	PORTB,1		;
		goto	sw1		;
turnon1	             bsf	PORTB,1		;
		goto	sw1		;
em không biết phải giải quyết làm sao nữa. mong mấy anh giúp đỡ. em cảm ơn trước