PIC16F877 to PC via max232 HELP!!
I hope one of you can help me, I am having lots of problems and not getting anywhere fast.
I am trying to connect a 20Mhz PIC16F877 to a PC using a MAX232 and PicBasic. I need to use the features of hserin and hserout for my project not serin and serin2.
I think from what I read so far its not possible to connect the the PIC to the MAX then to the port directly due to some inverting thing which I really dont understand.
I wonder if anyone could give me some working code to echo data sent from the pc back from the PIC so I can be sure to get started.
Also if you have a diagram of the circuit that works, I would be very greatful.
I am using Pic Basic pro 2.45 and an Epic programmer that both work ok and I have ran plenty tests to check.
Please help.
Loredana
PIC16F877 to PC via max232 HELP!!
Thanks mister_e,
That worked at 9600,
Lost me why DEFINE HSER_SPBRG 129 I cannot find any reference to that in the picbasic manual.
Also I did get a compiler error about an op code with this:
@ __config _HS_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF
I guessed, added a rem before it then added this DEFINE OSC 20 and it compiled ok.
All I need now is to get to the 19200 and I will be happy.
Do I need to just change the DEFINE HSER_SPBRG 129 value to reach 19200
Thank you also for the gif with the diagram, that helped a lot aswell.
Lory
PIC16F877 to PC via max232 HELP!!
Hi Again Steve,
It worked alright, meaning the 64.
19,200 and singing, thanks to you.
I am looking now at another thing, maybe you can help me here too.
I want the program to wait untill I sent it **play# then react to the digital that follow upto a certain ending character like !
This compiles and works
HSERIN [WAIT("**play#")]
Then I wanted to the processor to pic up the next 6 characters after the **play#, so I send to the PIC **play#123456. looking at other examples the code should be like this:
HSERIN [WAIT("**play#")STR data\6]
wait for **play# then then next 6 characters will be present in data, well I wish, I get an error with syntax
ERROR Line 59: Expected ']'.
Also I read in the manual STR ArrayVar\n{\c}
Receive string of n characters optionally ended in character c
Does this mean I dont have to specify the value of n
HSERIN [WAIT("**play#")STR data\n\"!"]
wait for **play# and copy the next characters upto the ! to data.
Or am I getting totallly mixed up.
Have you got a few examples I could try.
Hope I am not imterupting you steve with all these questions.
Loredana.
PIC16F877 to PC via max232 HELP!!
lala, that was funny, thanks you made me laugh.
Both these work well steve
HSERIN [WAIT("**play#"), STR lala\10\"!"]
hserout [str lala\10]
Well you said it was ok to ask so I have another.
loop:
HSERIN [WAIT("**play#"), STR lala\10\"!"]
' **play#hockey!
' **play#tennis!
' **play#pool!
' **play#badmington!
lala will be contain one of these, can I make them into one string to allow an if statement to branch to different code.
I see I could do this with simple numbers like 1,2,3,4,5 etc but I want to use strings style names if possible.
I found some code that some guy had done like this:
IF relay = 1 THEN outr1 ' if request is for relay#1 then goto relay#1 routine
I would like to make it like this:
If lala\10 = "badmington" then badmington
badmington:
' the code for badmington
GOTO loop
Is that possible Steve
Thanks again
Lory