Hi, i just realized that I typed my code in wrong. I had it the way you suggested but it still doesn't work. any other ideas of what could be wrong?
Thanks for any more help.
Hi, i just realized that I typed my code in wrong. I had it the way you suggested but it still doesn't work. any other ideas of what could be wrong?
Thanks for any more help.
Well, it wasn't really a suggestion. I was just pointing out part of the problem.
My suggestion would be to place the b0 = 0 line just prior to the IF PortB.1 = 1 line. Like this...And, add a short pause in the loop. Just to space things out a bit.Code:Tx: Include "modedefs.bas" b0 VAR BYTE Start: LET b0 = 0 IF PortB.1 = 1 THEN LET b0 = 1 SEROUT PortB.0, N2400, [b0] PAUSE 10 GOTO Start
Then on the receiving end...Code:Rx: Include "modedefs.bas" b0 VAR BYTE Start: SERIN PortB.0, N2400, [B0] IF b0 = 1 THEN HIGH PortB.1 ELSE LOW PortB.1 ENDIF GOTO Start
DT
Start:
LET b0 = 0
IF PortB.1 = 1 THEN LET b0 = 1
SEROUT PortB.0, N2400, [b0]
PAUSE 10
GOTO Start
Don't forget the "ENDIF"
Start:
LET b0 = 0
IF PortB.1 = 1 THEN LET b0 = 1
* ENDIF*
SEROUT PortB.0, N2400, [b0]
PAUSE 10
GOTO Start
Hi, I tried Ron Marcus's "endif" and it did not compile. nothing seems to be working and I am beginning to thing that I should try the HSERIN and HSEROUT commands instead. My actual application will be a PIC 18F4320 PIC controlling 12 servos and monitoring 12 pushbuttons. The idea is to take the load of controlling servo motion routines of the master controller. I want to control the motion routines of the servos with the master controller via serial link. Does anyone have any ideas? I think that the hardware serial port would make the timing requirements easier to deal with but I do not fully understand the HSERIN HSEROUT commands and USAURT could someone please explain all this to me?
O.K... Try this,
Start:
b0 = 0
IF PortB.1 = 1 THEN
b0 = 1
ENDIF
SEROUT PortB.0, N2400, [b0]
PAUSE 10
GOTO Start
Now, it looks like you are using Stamp type conventions for labels. b0 is not very descriptive.
button1 var portc.0
This will alias the above port pin (can be any pin) so you can use a more descriptive term and it will be easier to follow the program in the future. Also, "Let" is unnecessary with PBP. It will still work,and if it is habit, then do it. Do you have the apropriate pullup(down) resistors for your switches?
HI, I tried the code that Ron Marcus posted and it did not work. I think the problem is in the receiver PIC software, (when I hook a speaker up to the serial line I can hear the data flowing). I have now tried several ways to make a serial connection but none worked. These attempts included DEBUG and DEBUGIN commands as well as HSERIN and HSEROUT commands. I would be extremely happy if someone could post some sample code and hardware information on getting a serial connection working between two PICs using any method ( HSERIN, DEBUG ect.). I appreciate any help you can offer on this problem.
Bookmarks