User manual
mikroC PRO for dsPIC
MikroElektronika
411
do
{
temp = 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
temp = 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 (temp != 0x0E) // If "End" byte was received(see Transmitter example)
Lcd_Chr_CP(temp); // do not write received byte on LCD
}
Delay_ms(25);
}
while (temp != 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() {
ADPCFG = 0xFFFF; // Congure AN pins as digital I/O
TRISB = 0;
LATB = 0;
Man_Send_Init(); // Initialize transmitter
while (1) { // Endless loop
Man_Send(0x0B); // Send "start" byte
Delay_ms(100); // Wait for a while
character = s1[0]; // Take rst char from string
index = 0; // Initialize index variable