User manual

mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
385
end;
repeat
begin
byte_rcvd := Man_Receive(error); // Attempt byte receive
if (error <> 0) then // If error occured
begin
Lcd_Chr_CP(‘?’); // Write question mark on LCD
Inc(ErrorCount); // Update error counter
if (ErrorCount > 20) then // In case of multiple errors
begin
Man_Synchro(); // Try to synchronize again
//Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount := 0; // Reset error counter
end;
end
else // No error occured
begin
if (byte_rcvd <> 0x0E) then // If “End” byte was received(see Transmitter example)
begin // do not write anymore received byte on LCD
Lcd_Chr_CP(byte_rcvd); // else write character on LCD
Inc(chr_counter); // Counts how many chars have been written on LCD
if (chr_counter = 25) then // If there were more then 25 characters
begin // synchronization is off
Lcd_Cmd(_LCD_CLEAR); // Clear the LCD of garbled communication
Man_Synchro(); // Try to synchronize again
end;
end
else
chr_counter := 0; // reset chr_counter
end;
Delay_ms(25);
end;
until (byte_rcvd = 0x0E);
end; // If “End” byte was received exit do loop
end.
The following code is code for the Manchester transmitter, it shows how to use the Manchester Library for transmitting data:
Copy Code To Clipboard
program Manchester_Transmitter;
// Manchester module connections
var MANRXPIN : sbit at RF0_bit;
MANRXPIN_Direction : sbit at TRISF0_bit;
MANTXPIN : sbit at LATF1_bit;
MANTXPIN_Direction : sbit at TRISF1_bit;
// End Manchester module connections
var index, character : byte;
s1 : array[17] of char;
begin
s1 := ‘mikroElektronika’;
ADPCFG := 0xFFFF; // Congure AN pins as digital I/O
Man_Send_Init(); // Initialize transmitter
while TRUE do // Endless loop