AN #101 - BASCOM-AVR example that demonstrates SNAP protocol



This first AVR application note is donated by Mike Eitel.

The program shows how to implement the S.N.A.P protocol in BASCOM and is a simple example to turn a LED ON or OFF. It uses PLM-24 Power Line Modems to communicate over the power lines (mains).

This example uses 16-bit CRC-CCITT as error detection method which gives secure data transfer.

This small program gives you some starter for AVR 8515 with S.N.A.P protocol.

It is tested with original STK200 kit.
I use 8 additional LED on Port C and 1 LED from MISC pin OC1B to see results. (LED + 1k to VCC)
You can see:
Port A : Not used
Port B : The value of the so called commands
Port C : The value of the send data
Port D : Not used
Pin OC1B : The frequency of the Timer1 ( slower if interrupt enabled)

I used the SNAP16 and the DEMO2 program from HTH as base of my modifications.

AVR is node 4, the PC (NT4 SP5) is node 1.
Preambles are "M" for the master and "S" for the slave.

All telegrams use 1 Byte data.

To AVR you send via SEND or +1 button. See result at Port C.

For data request I implemented command codes, means you can give a command ( 0 to 255 ) in the field and press the READ button. Then the AVR send his data to the master.

There are momentary 3 commands implemented:

128 requests the momentary value of timer1's low byte.
129 starts interrupt timer1 ( decrementing value of db1 and sends value to master )
130 stops interrupt timer1

The VB program is written with VB5 called SNAP.BAS
The AVR is written with BASCOM AVR called _Mike_SNAP.

Download source code in an101.zip