Datasheet
Library Example
The following code is code for the Manchester receiver, it shows how to use the
Manchester Library for receiving data:
// LCD module connections
sbit LCD_RS at PORTD.B2;
sbit LCD_EN at PORTD.B3;
sbit LCD_D4 at PORTD.B4;
sbit LCD_D5 at PORTD.B5;
sbit LCD_D6 at PORTD.B6;
sbit LCD_D7 at PORTD.B7;
sbit LCD_RS_Direction at DDRD.B2;
sbit LCD_EN_Direction at DDRD.B3;
sbit LCD_D4_Direction at DDRD.B4;
sbit LCD_D5_Direction at DDRD.B5;
sbit LCD_D6_Direction at DDRD.B6;
sbit LCD_D7_Direction at DDRD.B7;
// End LCD module connections
// Manchester module connections
sfr sbit MANRXPIN at PINB.B0;
sfr sbit MANRXPIN_Direction at DDRB.B0;
sfr sbit MANTXPIN at PORTB.B1;
sfr sbit MANTXPIN_Direction at DDRB.B1;
// End Manchester module connections
char error, ErrorCount, temp;
void main() {
ErrorCount = 0;
Manchester_Stop();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(LCD_CLEAR); // Clear LCD display
Man_Receive_Init(); // Initialize Receiver
while (1) { // Endless loop
Lcd_Cmd(LCD_FIRST_ROW); // Move cursor to the 1st row
while (1) { // Wait for the "start" byte
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
break; // We got the starting sequence
if (error) // Exit so we do not loop forever
break;
}
319
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6