HI , i have a little project...i have problem in sending data from one pic to another PIC using serin and serout...i'm using keypad to get the input(therefore the input will be a number) and i want to send it to the second pIC and display it on the LCD.
The problem is when i press the keypad, when i display it on the LCD it always give 0..i'm sure myway accessing the keypad is correct but the way to sending the data to the another pic maybe isn't correct..
CAN ANY ONE HELP ME PLEASE WITH THIS PROBLEM BECAUSE I ONLY HAVE 2WEEKS LEFT BEFORE MY PROJECT due date time..
HERE IS MY CODE
---------KEYPAD(TRANSMITTER)---------
INCLUDE "bs2defs.bas"
DEFINE CHAR_PACING 500
ANSEL=0
TRISC = %10000111 ; port for keypad
TRISB = %00000000
dgood var portB.4 ;indicate that anykey has been pressed or not
outpin var portB.7 ; output to another PIC
col1 var portC.0
col2 var portC.1
col3 var portC.2
row1 var portC.3
row2 var portC.4
row3 var portC.5
row4 var portC.6
val var byte
define OSC 8
getkey:
pause 50
high dgood ; if high no key is pressed
;check which number has been pressed
row1=0
if col1 = 0 then one
if col2 = 0 then two
if col3=0 then three
row1 =1
row2=0
if col1 = 0 then four
if col2 = 0 then five
if col3=0 then six
row2 =1
row3=0
if col1 = 0 then seven
if col2 = 0 then eight
if col3=0 then nine
row3 =1
row4=0
if col1 = 0 then star
if col2 = 0 then zero
if col3=0 then hash
row4 =1
goto getkey
one:
val =1
goto valid
two:
val =2
goto valid
three:
val =3
goto valid
four:
val =4
goto valid
five:
val =5
goto valid
six:
val=6
goto valid
seven:
val =7
goto valid
eight:
val =8
goto valid
nine:
val =9
goto valid
star:
val =%00101010
goto valid
hash:
val =%00100011
goto valid
valid:
low dgood ; if any key pressed make it low and star send data
serout outpin,t2400,[val]
keypress:
if (col1&col2&col3)<>1 then keypress;check if key has been released or not
goto getkey
------------------receiver---------------
INCLUDE "bs2defs.bas"
DEFINE LCD_DREG portC
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG portA
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG portA
DEFINE LCD_EBIT 1
DEFINE LCD_LINES 2
DEFINE LCD_BITS 8
DEFINE LOADER_USED 1
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAAUS 250
DEFINE OSC 8
ABSEL =0
trisB=%11111111
keyinput var portB.5 ;port that received data from the transmitter
num var byte ; containing the numbers that will be display
valid var byte;indicator that key has been pressed and start receive data
pause 50
loop:
lcdout $FE,1
LCDOUT $FE,$80
lcdout "ENTER polarity"
LCDOUT $C0
LCDOUT "1)+ 2)-"
gosub wait1
LCDOUT $FE,$C0+11,#num
pause 500
goto loop
wait1: ;wait until key has been pressed
if valid =1 then wait1
serin keyinput,t2400,num
wait2:;wait until key has been released
if valid = 0 then wait2
return
end
HOPE U GUYS CAN HELP ME>..THANX VERY MUCH
end
thanx
Bookmarks