Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
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
var LCD_RS : sbit at PORTD.B2;
LCD_EN : 
sbit at PORTD.B3;
LCD_D4 : 
sbit at PORTD.B4;
LCD_D5 : 
sbit at PORTD.B5;
LCD_D6 : 
sbit at PORTD.B6;
LCD_D7 : 
sbit at PORTD.B7;
var LCD_RS_Direction : sbit at DDRD.B2;
LCD_EN_Direction : 
sbit at DDRD.B3;
LCD_D4_Direction : 
sbit at DDRD.B4;
LCD_D5_Direction : 
sbit at DDRD.B5;
LCD_D6_Direction : 
sbit at DDRD.B6;
LCD_D7_Direction : 
sbit at DDRD.B7;
// End Lcd module connections
// Manchester module connections
var MANRXPIN : sbit at PINB.B0;
MANRXPIN_Direction : 
sbit at DDRB.B0;
MANTXPIN : sbit at PORTB.B1;
MANTXPIN_Direction : 
sbit at DDRB.B1;
// End Manchester module connections
var error, ErrorCount, temp : byte;
begin
ErrorCount := 0;
Delay_10us();
Lcd_Init();                            // Initialize Lcd
Lcd_Cmd(LCD_CLEAR);                     // Clear Lcd display
Man_Receive_Init();                      // Initialize Receiver
while TRUE do
// Endless loop
begin
Lcd_Cmd(LCD_FIRST_ROW);        // Move cursor to the 1st row
while TRUE do
// Wait for the "start" byte
begin
temp := Man_Receive(error);           // Attempt byte receive
if (temp = 0x0B) then 
// "Start" byte, see Transmitter example
267
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6