Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
359
Library Example
The following code is code for the Manchester receiver, it shows how to use the Manchester Library for receiving data:
Copy Code To Clipboard 
// LCD module connections
sbit LCD_RS at LATB2_bit;
sbit LCD_EN at LATB3_bit;
sbit LCD_D4 at LATB4_bit;
sbit LCD_D5 at LATB5_bit;
sbit LCD_D6 at LATB6_bit;
sbit LCD_D7 at LATB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// 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
unsigned int error;
char ErrorCount, chr_counter, byte_rcvd;
void main() {
  ErrorCount = 
0
;
  chr_counter = 
0
;
  CHECON = 
0x32
;
  AD1PCFG = 
0xFFFF
;                               
// Configure AN pins as digital I/O
  TRISB = 
0
;
  LATB = 
0
;
  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
        byte_rcvd = Man_Receive(&error);          
// Attempt byte receive
        if (byte_rcvd == 
0x0B
)               
// “Start” byte, see Transmitter example