I hate to sound like a broken record - but... Always use the hardware serial port if your device has one. You will be glad you did.
I hate to sound like a broken record - but... Always use the hardware serial port if your device has one. You will be glad you did.
Charles Linquist
Thanks Dave and Charles :-)
But where do I start with hardware ports?
I got the impression reading through the forums that software serin/out and serin2/serout2 and debug would be easier to play around with.
I ssetting up the hardware option just as easy ?
I also read somewhere that serin needs to be setup to look for something first before it starts accepting data ? Is this why I after one keypress, nothing else appears on the LCD ?
Is there a some code I could use just to test the TX/RX function between 2 PIC's using wires ( see my diagram in earlier posts) , once I have that working I can then move onto TX and RX using wireless
Something like setup PIC A to send a string or a byte to PIC B and then have PIC B send the same byte to hyperterminal(pc).
Could I use serin2 first then serout (not serout2) to send the string or byte to hyperterminal(pc).
Have I made the correct choice for send and receive ports ..on both pics PORTC.6 and PORTC.7
Any help or advice would really be appreciated.
Kind regards
Dennis
Dennis,
A few thoughts on linking PICs by RS232:
1. I've done it - unfortunately, deleted the code after getting it working.
2. I used SERIN2 and SEROUT2, by habit rather than for good technical reasons.
3. HSEROUT/HSERIN do pass much of the processing down to the chip hardware and save lots of processing time and code space. However, if you are still in the 'getting something working stage' I'd use SEROUT/SERIN to avoid additional DEFINES and so on needed for HSEROUT/IN.
4. I've had a short read through your code and not spotted any problems. I'd suggest that you temporarily abandon the keypad business and write a very basic routine to send/receive one byte variable PIC-Hyperterm and then PIC-PIC. Start using SEROUT/SERIN then move on to SEROUT2/SERIN2 and then HSEROUT/HSERIN.
5. Have you got carriage returns (Decimal '13') at the end of each transmission?
6. I've not looked up the data for your chips but what is TRISX?
7. Just had a longer look at the code and I think your sequencing is wrong? Should be:
a. PICA. Press key
b. PICA. Send to the other PIC (I think you receive here?)
c. PICB. Receive data
d. PICB. Send data
e. PICA. Receive data
f. PICA. Display data on LCD
g. PICA. Press key......
Watch those CRs!
8. I assume that each end of the PIC to PIC RS232 link is symetrical i.e both have RS232 chips for level conversion or both do not?
Regards Bill legge
Hi Bill
Thanks a million for the informative response and advice :-)
Here is my reply to your examination :
1.Damn, just my luck ! Nice to hear you came right though :-0
2.I wouldn't mind using either have those but found issues with serout2 and the data displayed in hyperterminal so used serout.
What are your thoughts on using DEBUG ?
3.I did notice in reading through other forum posts and the manual that DEFINES are required.
4.I was thinking of doing exactly the same thing just to remove also possible room for error :-)
5. No I do not have carriage returns at the end of each transmission are you referring to 10,13 at the end of serout ?
I was under the notion that I could just SEROUT ping and port at 2400T and the variable name all in a loop.... is this where my problem is...apart from being a little rusty and having to re-live been a PIC newbie again ?
6.TRISX is a very secret register which you enable my moving the shift in the time space continum on a PIC 18f4520 ....:-) lol just kidding.
OK jokes aside TRISX is the comment I placed there so that I could remember how to manipulate TRIS for IO.
7. Sequencing is correct ...just realised I have not added the connection diagram :-( will add it to this post now.
I am sending from PIC 16f887 PIC 18F4520
PORTC.6(TX)-----PORTC.7(RX)
PORTC.7(RX)-----PORTC.6(TX)
so it's PIC16F887 >>PIC18F4520 >>PC(hyperterminal)
out in | out
TX RX | TX
|
LCD IS HERE (wired to 18F4520)
Once again ...where are the CR's and where should they go exaclty ?
8.The only place there is a MAX232N is on the TX side of the 18F4520 so that is can connect to PC serial port, in which case I am able to send and receive data to and from the PC :-)
Hope this helps , will post more info just now to make it simpler to read ;-)
Any more info would be much appreciated.
Kind regards
Dennis
Just to add to the confusion...
DEFINES are not required.
Demo:
Sometimes complete control is handy.Code:X VAR BYTE START:X = X + 1 HIGH PORTD.2 :PAUSE 250:LOW PORTD.2:PAUSE 250 RCSTA=$90:TXSTA=$24:SPBRG=129:HSEROUT ["HSER ",DEC X,13,10] PAUSE 250:RCSTA=$0:SEROUT2 PORTC.6,84,["SER ",DEC X,13,10] GOTO START
Dave
Always wear safety glasses while programming.
Hi Dave ...how are you ?
Mmmm that sure got me :-)
An here I am still trying to at least get some comms going :-( !
I have the champagne ready ...now just to find the ship to smash it open on and the people to join my 'I can finally TX/RX' between PIC's celebrations...
All I can say for now is... WATCH THIS SPACE ! LOL
Kind regards
Dennis
Smoke and mirrors???
Here is a simple example to build on
SEND:
RECEIVE:Code:SEROUT PORTC.4,T2400,[9,3]
Connect VSS and the two PIC pins together.Code:SERIN PORTC.4,T2400,[9],net IF net = 3 THEN DO_SOMETHING
Dave
Always wear safety glasses while programming.
Bookmarks