Mikroelektronika MIKROE-724 データシート
386
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Library Example
The following code is code for the Manchester receiver, it shows how to use the Manchester Library for receiving data:
Copy Code To Clipboard
program Manchester_Receiver
‘ LCD module connections
dim LCD_RS as sbit at LATD0_bit
LCD_EN as sbit at LATD1_bit
LCD_D4 as sbit at LATB0_bit
LCD_D5 as sbit at LATB1_bit
LCD_D6 as sbit at LATB2_bit
LCD_D7 as sbit at LATB3_bit
dim LCD_RS_Direction as sbit at TRISD0_bit
LCD_EN_Direction as sbit at TRISD1_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
‘ End LCD module connections
‘ Manchester module connections
dim MANRXPIN as sbit at RF0_bit
MANRXPIN_Direction as sbit at TRISF0_bit
MANTXPIN as sbit at LATF1_bit
MANTXPIN_Direction as sbit at TRISF1_bit
‘ End Manchester module connections
dim error_flag, ErrorCount, counter, temp as byte
main:
ErrorCount = 0
counter = 0
ADPCFG = 0xFFFF ‘ Configure AN pins as digital I/O
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_flag) ‘ Attempt byte receive
if (temp = 0x0B) then ‘ “Start” byte, see Transmitter example
break ‘ We got the starting sequence
end if
if (error_flag <> 0) then ‘ Exit so we do not loop forever
break
end if
wend