PDA

View Full Version : pic 2 pic pic'n my brains out!



earltyso
- 10th April 2008, 17:33
Hello all,
I have been multiplexing a keypad to my hyperterminal with no problems!
Now I am trying a more simple program from PIC-2-PIC with no success. I have checked all the basics, ADCON settings, baud rates, modes, qualifier and I am stumped. I have included my code in hopes I made a simple mistake someone with more experience will find.

'transmitter pic16f628a
CMCON = 7
include "modedefs.bas"
'all other i/o info
intro:'...all my other stuff
main:
while switch = 0
serout portb.5,n2400,["A",#55] 'I am sending the decimal value 7 to portc of the other pic
pause 1
wend
goto intro
end


'reciever pic16f877
adcon1=7
include "modedefs.bas"

'all other i/o info

main:
serin porta.0,n2400,["A"],B0 'A is the qualifier , then store a decimal number in B0
portc=B0' send 7 to port c so I have C.0, C.1, C.2 leds come on
got main

thanks,

mister_e
- 10th April 2008, 17:36
is it possible to post the whole codes and OSC speed?

And post your code in code boxes



paste your code here


this will looks like


paste your code here


so your codes stay indented.. more readable.

mackrackit
- 10th April 2008, 18:12
serout portb.5,n2400,["A",#55] 'I am sending the decimal value 7 to portc of the other pic

From the manual

3) A numeric value preceded by a pound sign ( # ) will send the ASCII representation of its decimal value. For example, if W0 = 123, then #W0 (or #123) will send '1', '2', '3'.

earltyso
- 10th April 2008, 21:45
I have been wondering how to post code in box form for a while...



'transmitter side pic16f628a
Include "modedefs.bas"
Define OSC 4
CMCON = 7

input PORTB.0
OUTPUT PORTB.5
OUTPUT PORTA.0
SWITCH VAR PORTB.0
Buzzer VAR PORTB.5
x VAR BYTE

INTRO:
for x = 0 to 1
high buzzer
pause 50
low buzzer
pause 50
next x

main:
while switch = 0
SEROUT PORTB.5,N2400, ["A",#55]
PAUSE 1
WEND
GOTO INTRO
END




'receiver pic16f877
INCLUDE "modedefs.bas"
DEFINE OSC 12
ADCON1 = 7 'all digital inputs, good to go now!!

input PORTA.0 'SERIAL INPUT
Output PORTA.5 'L1
Output PORTE.0 'L2
Output PORTE.1 'L3
Output PORTE.2 'L4
Output PORTC.0 'L5
Output PORTC.1 'L6
Output PORTC.2 'L7
Output PORTC.3 'L8
INPUT PORTD.0 'RX1
INPUT PORTD.1 'RX2

Output PORTD.7 'RELAY4
Input PORTD.5 'BACK
Input PORTD.4 'NXTSLT
Input PORTC.7 'UP
Input PORTC.6 'DOWN
Input PORTC.5 'RX6
input PORTC.4 'RX5
input PORTD.3 'RX4
input PORTD.2 'RX3

L1 VAR PORTA.5 '8 lights
L2 VAR PORTE.0
L3 VAR PORTE.1
L4 VAR PORTE.2
L5 VAR PORTC.0
L6 VAR PORTC.1
L7 VAR PORTC.2
L8 VAR PORTC.3
Relay4 VAR PORTD.7
tx1 VAR PORTD.0 'reciever 6 inputs
tx2 VAR PORTD.1
tx3 VAR PORTD.2
tx4 VAR PORTD.3
tx5 VAR PORTC.4
tx6 VAR PORTC.5
back VAR PORTD.5
nxtslt VAR PORTD.4
up VAR PORTC.7
down VAR PORTC.6
B0 VAR byte

low l1:low l2:low l3:low l4:low l5:low l8: low relay4

start:
LCDOut 254,1
Pause 1000
High L1
Pause 90
Low L1
High L2
Pause 90
Low L2
High L3
Pause 90
Low L3
High L4
Pause 90
Low L4
High L5
Pause 90
Low L5
High L6
Pause 90
Low L6
High L7
Pause 90
Low L7
High L8
Pause 90
Low L8
HIGH Relay4
PAUSE 90
LOW RELAY4

main:
SERIN PORTA.0,N2400, ["A"],B0
'PAUSE 1
PORTC = B0
GOTO MAIN


As this is only a test, I just want to see something on my pcb to show that I have good serial data coming in (leds on portc) then I will move on to LCD text input output from pic16f628a multiplexed keypad...
thanks for the help with the text boxes!

mister_e
- 10th April 2008, 21:58
So your serial data is on the same pin as your Buzzer?

Did you set HS_OSC fuse for your F877?

Your PIC16F628 use the internal OSC? Sure the Config fuses are set for it?

As Dave suggested, you want to make sure your qualifiers match on Both Side. Two way here.. or you change #55 to 55 in your SEROUT line, or you change B0 to #B0 in your SERIN line.

earltyso
- 10th April 2008, 23:28
Looks like my reply did not come through,
yep I made some dumb mistakes....including, forgetting to set clock to HS on the 877, setting the correct output for my serial data on the 628a, and the way my data was sent #...thanks alot for the help

I am wondering...can you send serin/serout without using a qualifier?

mister_e
- 10th April 2008, 23:33
Yes you can!