Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial communication using pic 16f877a (usart)

Status
Not open for further replies.

Girishs449

Newbie level 5
Joined
Dec 12, 2016
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
92
Serial communication using pic 16f877a

Hi friends, i'm doing a circuit for communicating 2 pic's in master and slave mode.
In this data from port B of master is transmitted in serial to the slave and output the data to port B of slave.
but its not working. there is no response.
I'm using pic 16f877A, 20MHZ xtal.
please help

here is the circuit
SERIAL.png

code for master


Code:
	TITLE  "SERIAL COMMUNICATION MASTER MODE.ASM"       
 	LIST P=16F877A, R=DEC
 	INCLUDE "P16F877A.INC"

	; DATA SEGMENT
                 
 
 	PAGE
 	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF  

  	ORG 0X00                      	; START PROGRAM AT THE BEGINNING OF MEM
BCF STATUS, RP0 			;
BCF STATUS, RP1 			; BANK0
CLRF PORTB 
BSF STATUS, RP0 			; SELECT BANK 1
MOVLW 0XFF 
MOVWF TRISB
BCF STATUS, RP0 			;

MAINLINE

MOVLW B'00110000'                       ; ENABLE SPI MODE, CLOCK, MASTER 
MOVWF SSPCON 
MOVF PORTB, W                           ; READ PORTB VALUE 
MOVWF SSPBUF                            ;  TRANSMIT VALUE TO SLAVE 
NOP 
NOP 
NOP 
GOTO MAINLINE                           ; REPEAT THE PROCESS
END




code for slave


Code:
	TITLE  "SERIAL COMMUNICATION SLAVE MODE.ASM"              
 	LIST P=16F877A, R=DEC
 	INCLUDE "P16F877A.INC"

	; DATA SEGMENT
                 
 
 	PAGE
 	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC& _WRT_OFF & _LVP_OFF & _CPD_OFF

ORG 0000H                            ; RESET ADDRESS 
GOTO start
ORG 0020H                            ; MAIN PROGRAM ADDRESS
start
BCF STATUS, RP0 		    ;
BCF STATUS, RP1 		    ; BANK0
CLRF PORTB 
BSF STATUS, RP0 		    ; SELECT BANK 1
MOVLW 0X00 
MOVWF TRISB

MAINLINE:   
       
BSF STATUS, RP0             	    ; BANK 1
BSF PIE1, SSPIE                     ; ENABLE SSP INTERRUPT 
BCF STATUS, RP0                     ; BANK 0 
BCF PIR1, SSPIF                     ; CLEAR SSP INTERRUPT FLAG 
BSF INTCON, PEIE                    ; ENABLE PERIPHERAL INTERRUPT 
BSF INTCON, GIE                     ; ENABLE GLOBAL INTERRUPT

LOOP:  GOTO LOOP                    ; INFINITE LOOP

ORG 0004H                           ; INTERRUPT SUB-ROUTINE ADDRESS 
MOVF SSPBUF, W                      ; READ SSPBUF 
MOVWF PORTB                         ; WRITE SSPBUF VALUE TO PORT B 
RETIE   			    ; RETURN
END
 
Last edited:

You don't need MISO line for unidirectional data transmission, but slave select for frame synchronization.

The thread title is contradicting the actual implementation, you say USART but have SPI interface.
 

ok. but i dont know what is MISO.
how can i rectify the problem.
 

Re: Serial communication using pic 16f877a (SPI)

MISO means Master In Slave Out also SDI
MOSI means Master Out Slave In also SDO
 
thanks. i found these codes in a toturial. i dont know how to rectify the problem. what all things i need to correct in the code?
 

Needless usage of assembler code seems to me as a kind of self-flagellation respectively masochism. Microchip has free XC8 C compiler.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top