Datasheet

Library Example
The following code is code for the Manchester receiver, it shows how to use the
Manchester Library for receiving data:
program Manchester_Receiver
' Lcd module connections
dim LCD_RS as sbit at PORTD.B2
LCD_EN as sbit at PORTD.B3
LCD_D4 as sbit at PORTD.B4
LCD_D5 as sbit at PORTD.B5
LCD_D6 as sbit at PORTD.B6
LCD_D7 as sbit at PORTD.B7
dim LCD_RS_Direction as sbit at DDRD.B2
LCD_EN_Direction as sbit at DDRD.B3
LCD_D4_Direction as sbit at DDRD.B4
LCD_D5_Direction as sbit at DDRD.B5
LCD_D6_Direction as sbit at DDRD.B6
LCD_D7_Direction as sbit at DDRD.B7
' End Lcd module connections
' Manchester module connections
dim MANRXPIN as sbit at PINB.B0
MANRXPIN_Direction as sbit at DDRB.B0
MANTXPIN as sbit at PORTB.B1
MANTXPIN_Direction as sbit at DDRB.B1
' End Manchester module connections
dim error_, ErrorCount, temp as byte
main:
ErrorCount = 0
Delay_10us()
Lcd_Init() ' Initialize Lcd
Lcd_Cmd(LCD_CLEAR) ' Clear Lcd display
Man_Receive_Init() ' Initialize Receiver
while TRUE ' Endless loop
Lcd_Cmd(LCD_FIRST_ROW) ' Move cursor to the 1st row
while TRUE ' Wait for the "start" byte
temp = Man_Receive(error_) ' Attempt byte receive
if (temp = 0x0B) then ' "Start" byte, see Transmitter example
break ' We got the starting sequence
end if
if (error_ <> 0) then ' Exit so we do not loop forever
break
end if
wend
252
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6