PDA

View Full Version : sending data - numbers between PICs



tbarania
- 21st April 2015, 22:17
I must not be thinking about this right. I need to send an "R", either a "2" or "4", and then a 4 digit decimal number from one PIC to another using hserin and hserouthserin and serout2. Ideally I would like to be able to detect the R when the R##### characters come but first things first. Using a PIC16F688 at 8MHz at 1200 baud.

This is what I send:
hserout [ "R", "2", dec4 volts] 'where volts is a 4 digit decimal number

This is how I am looking for it on the receiving PIC:
hserin 800, rinse,[syncr, drip, dec4 volts]

I then print it to a computer for display using:
serout2 Txd, 813, ["got it_1", 9, syncr, 9, drip, 9, dec4 volts, 13]

Nothing shows up as output, not even the "got it" text, as if it never gets to this point. I would like to be able to, depending on whether drip is a "2" or a "4", do different things. I think I've done this very thing on other projects so I'm mystified why this doesn't work.

Thanks for any help.

HenrikOlsson
- 22nd April 2015, 06:49
Hi,
Couple of random thoughts:
Are you perhaps mixing up the baudrate on the two interfaces?
Have you configured the pin used for the SEROUT2 correctly, no ADC, comparator or anything like that.
Have you configured the terminal software on the PC for the correct baudrate that SEROUT2 uses?
Are you using a level converter between the PIC and PC?
Can you display a startup message, to the PC, using SEROUT2 to verify that THAT part works?
Have you setup the USART for the correct baudrate on both the sending and the receiving PIC and what baudrate is that?

/Henrik.

tbarania
- 22nd April 2015, 23:04
Thanks for your tips.

I think the problem may have been in the computer terminal program. I tried a different baud rate - 2400 - and it all worked. I went back to the original 1200 baud and it still worked. Nothing happened in between other than the baud rate was set and reset.

Tom

HenrikOlsson
- 23rd April 2015, 06:05
What's the physical connection between the PIC and PC?
Some "virtual" serial ports, like Bluetooth module for example, don't really care what you set the baudrate to (on the PC).
Anyway, if it works and you're happy with that then everything's fine.

/Henrik.