User manual

Table Of Contents
360
mikoC PRO for PIC32
MikroElektronika
break; // We got the starting sequence
if (error) // Exit so we do not loop forever
break;
}
do
{
byte_rcvd = Man_Receive(&error); // Attempt byte receive
if (error) { // If error occured
Lcd_Chr_CP(‘?’); // Write question mark on LCD
ErrorCount++; // Update error counter
if (ErrorCount > 20) { // In case of multiple errors
Man_Synchro(); // Try to synchronize again
//Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount = 0; // Reset error counter
}
}
else { // No error occured
if (byte_rcvd != 0x0E) { // If “End” byte was received(see Transmitter example)
// do not write anymore received byte on LCD
Lcd_Chr_CP(byte_rcvd); // else write character on LCD
chr_counter++; // Counts how many chars have been written on LCD
if (chr_counter == 25) { // If there were more then 25 characters
// synchronization is off
Lcd_Cmd(_LCD_CLEAR); // Clear the LCD of garbled communication
Man_Synchro(); // Try to synchronize again
}
}
else
chr_counter = 0; // reset chr_counter
}
Delay_ms(25);
}
while (byte_rcvd != 0x0E); // If “End” byte was received exit do loop
}
}
The following code is code for the Manchester receiver, it shows how to use the Manchester Library for receiving
data:
Copy Code To Clipboard
// Manchester module connections
sbit MANRXPIN at RF0_bit;
sbit MANRXPIN_Direction at TRISF0_bit;
sbit MANTXPIN at LATF1_bit;
sbit MANTXPIN_Direction at TRISF1_bit;
// End Manchester module connections
char index, character;
char s1[] = “mikroElektronika”;
void main() {
CHECON = 0x32;