// if device and clock are omitted, then the compiler defaults to
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F2420
Clock = 20
// uses USART library...
Include "USART.bas"
Include "convert.bas"
Include "manchester.bas"
// working variables...
Dim ValueWord As Word
Dim ValueByte As Byte
Dim tx_out As PORTC.3
Dim led As PORTC.0
Dim x As Word
Output (tx_out)
Output (led)
led = 0
tx_out = 0
While 1 = 1
For x = 0 To 10 // cycle through 11 times
// encode a value, display the result...
//SetBaudrate(br19200)
ValueByte = %00000000
ValueWord = Manchester.Encode(ValueByte)
//Tx_out = (ValueByte, 8)
USART.Write("Encode ", BinToStr(ValueWord, 16), 13, 10)
PORTC.3 = ValueByte // send data out on c3
If tx_out = 1 Then
led = 1
else led = 0
delayms(2000)
End If
Next
Wend
{
// decode and display...
If Manchester.Decode(ValueWord, ValueByte) Then
USART.Write("Decode ", BinToStr(ValueByte, 8), 13, 10)
Else
USART.Write("ERROR!", 13, 10)
EndIf