» Home

» Products

» Interfaces

» Lab

» Downloads

» Buy It

» Contact

» Links

|
» Lab » Ping-Pong via SerialPIC or InfraPIC
| Project: | Ping Pong |
| Source Code: | PIC Assembler |
| 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 "bit bang" and "USART/ISR" methods.
Ping-Pong
: Zip file containing ASM and HEX files for both Bit-Bang and USART techniques (approx 5KB).
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.

This PIC code comprises of a simple loop which waits for an incoming character (from the terminal
emulator), adds 1 to the character code, and transmits it back to the sender. Hence the name ping-pong.
All communication is performed on a bit-by-bit basis in software (bit bang method).
The code comprises of the following subroutines:
InitPic: Initialises the PIC device
MainLoop: Main loop for receive, process and transmit
RxChSer: Receives using bit-bang method
TxChSer: Transmits using bit-bang method
WaitDelay: Utility delay routine used by above
This PIC code comprises of a simple loop which does nothing! Actually, this "busy" loop gets interrupted
on receiving a character. The interrupt is processed by the interrupt service routine which checks for receive
errors, and then adds 1 to the character code, and transmits it back to the sender.
All communication is performed in the background via the hardware USART. A much more elegant solution.
The code comprises of the following subroutines:
Isr: Interrupt Service Handler (receive,process,transmit)
Init: Initialises the PIC device
Loop: Could be doing something useful here
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).
|
|