» Home

» Products

» Interfaces

» Lab

» Downloads

» Buy It

» Contact

» Links

|
» Lab » Ping-Pong via SerialPIC or InfraPIC
| Project: | Ping Pong |
| Source Code: | PIC BASIC |
| PIC: | 16F628 |
| Interface: | SerialPIC or InfraPIC |
| Author: | Ravi Deo |
| Last Updated: | 7th April 2005 |

Project Description
This sample PIC project demonstrates demonstrates wired and wireless bi-directional communication.
It also demonstrates how to use a PIC16F628 with SirPic, to receive (ping) and
transmit (pong) characters using the SERIN and SEROUT command.
Ping-Pong
: Zip file containing BAS and HEX files.
Hardware Schematic
This project uses an external 4MHz resonator for a clock signal.
The PIC receive and transmit pins connect to the SerialPIC or InfraPIC interface.
The PIC communicates with SirPic on Palm via the interface.
SirPic locally echoes the transmitted character, followed by the incremented
character, returned by the PIC.

The source code comprises of a simple loop which waits indefinitely for a character.
The character is then incremented and transmitted back to the sender.
include "bs2defs.bas"
DEFINE CHAR_PACING 10
char VAR byte
loop:
SERIN PORTB.1,T9600,char ' wait for a character
char = char + 1 ' increment it
SEROUT PORTB.2,T9600,[char] ' transmit it back
Goto loop
If you are using the wireless InfraPIC interface, the Communication and Options settings should be configured as shown below.
However, if you are using the wired SerialPIC interface, then use "Port: Serial (RS232)".

Local echoing of characters will allow you to see the transmitted character, as well as the received
incremented character.
Power up the PIC application, and begin logging data on SirPic.
Using the grafitti pad, enter "A", this should be locally echoed on the screen.
This character should immediately be followed by the character "B" (reply from PIC).
|
|