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.

USART Receiving in MPLAB (PIC16F877A)

Status
Not open for further replies.

rohan0630056

Newbie level 4
Joined
Jun 17, 2009
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangladesh
Activity points
1,335
pic16f877a usart tutorial

I am trying to receive a number send from PC to the PIC16F877A. I learned to program on MPLAB... I can transmit data from PC to PIC but cant receive,, can any1 PLZ help me on this purpose. PLZ Help me...i cant find y the code is not working...can u plz tell me...

My code is given below:

list p=16f877
include <p16f877.inc>

org 0x00
goto start

start
bsf INTCON, GIE
bsf INTCON, PEIE
call initialPORTS
call initialSPAC
return

initialPORTS
bsf STATUS, RP0
movlw b'00000000'
movwf TRISB
movlw b'11000000'
movwf TRISC
bcf STATUS, RP0
clrf PORTB
clrf PORTC
return

initialSPAC
bsf STATUS, RP0
movlw b'00100100'
movwf TXSTA
movlw .25
movwf SPBRG
bcf STATUS, RP0
movlw b'10010000'
movwf RCSTA

loop
btfsc PIR1, 3
call initialREC
goto loop
return

initialREC
movf RCREG,0
movwf PORTB
return

end
 

rohan0630056

Newbie level 4
Joined
Jun 17, 2009
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangladesh
Activity points
1,335
pic16f877 usart example

Thx a lot....bt can u tell me the mistake i made..in my code... :)
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
mplab pic16f877a

Hi,


WHAT !!! I give you that good code example and you still want me to debug your code !!

Well you will have to call my premium rate help line at 500 TAKA per minute for the answer ! :wink:


You do not show your oscillator fequency, so cannot be 100% sure those Init settings are right.

However, if you compare your code with the example I showed, you will spot what I think is the only line of code in error.

Its a double fault, first you are checking the wrong bit and second you are doing the wrong test on it.
(the btfss/sc is an error I often used to make)

btfss PIR1, RCIF ;check for received data


Don't know what programmer you are using, but some of them like the Pickits do have an inbuilt Debugger and Usart tools that can be very helpfull.
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top