PDA

View Full Version : send and receive data using pic 16f84a



PoTeToJB
- 25th February 2006, 06:36
Need Help

I write the serout and serin command to send data from PIC to another PIC

can anyone tell me, how to solve it, thank you

i am try many way to solve it , but still cant solve it

i am using PIC16F84A model try a simple code below

TX DATA


INCLUDE "modedefs.bas"
DEFINE OSC 4

loop:
IF PORTB.0=0 Then
GoSub led_on
Else
GoSub led_off
EndIF
GoTo loop


led_on:
SerOut PORTB.1,N2400,[$FF,$FF,"OK","A"]
Return

led_off:
SerOut PORTB.1,N2400,[$FF,$FF,"OK","B"]
Return

End



RX DATA

INCLUDE "modedefs.bas"
DEFINE OSC 4
dataon VAR BYTE
led1 VAR PORTB.1
led2 VAR PORTB.2

Loop:

SerIn PORTB.0,N2400,["OK"],dataon
IF dataon="A" Then led_on
IF dataon="B" Then led_off
GoTo Loop

led_on:
High led1
Low led2
GoTo Loop

led_off:
Low led1
High led2
GoTo Loop

End

after i on the supply and push the switch the led does not light

to see the led light on/off how could be???

really need a help

thank you

BigWumpus
- 25th February 2006, 17:39
Huuuhh...

you fire a lot of charaters by the TX-PIC, and the RX-PIC has to do his work by software.

Just give him some time to does his work.
Read the PBP-manual around the SEROUT-command and look at the DEFINE CHAR_PACING !!!

Change the filling bytes from $FF to $00, maybe the RX-PIC will find the start of a new character even better.

PoTeToJB
- 27th February 2006, 17:00
thankQ BigWumpus .

now i try to send variable data to the another PIC and display the data in LCD HD44780.

can u help me

BigWumpus
- 27th February 2006, 18:27
Ahhmmm...

You read the PBP-manual ?
You have found SEROUT, what's about SEROUT2 ?

PoTeToJB
- 28th February 2006, 06:21
i have read pic basic manual in melabs but still cant understand it..

can u give me another source...

I am an amateur is PIC and pic basic pro program..

this is myprogramming code can u help me in solving my problem..

DEFINE CHAR_PACING
INCLUDE "modedefs.bas"
DEFINE OSC 4
cnt var byte

TrisB=%00000011
cnt=0
loop:
IF PORTB.0=1 Then
cnt=cnt+1
endif
if PORTB.1=1
GoSub senddata
EndIF
GoTo loop


senddata:
SerOut PORTB.1,N2400,["OK",#cnt]
return

End



RX DATA

symbol second = 1000
INCLUDE "modedefs.bas"
DEFINE OSC 4
dataon VAR BYTE

TrisB=%000000001
Pause second
lcd $FE,1,"READY"
Loop:

SerIn PORTB.0,N2400,["OK"],dataon
LcdOut $FE,#C0
LcdOut "Count= ",#dataon
GoTo Loop

End

my problem is the display doesnt show the correct data that is send from PIC

i use LCD HD44780

BigWumpus
- 28th February 2006, 20:12
I think you want to transfer byte-values.

Use

SerOut PORTB.1,N2400,["OK",cnt]

and

LcdOut $FE,$C0
LcdOut "Count= ",dec dataon