mikroC
mikroC - C Compiler for Microchip PIC microcontrollers
making it simple...
Library Example
unsigned short error, ErrorCount, IdleCount, temp, LetterCount;
void main() { ErrorCount = 0;
TRISC | = | 0; |
PORTC | = | 0; |
Man_Receive_Config(&PORTD, 6); Lcd_Init(&PORTB);
while (1) { IdleCount = 0;
do {
temp = Man_Receive(error); if (error)
ErrorCount++
else
PORTC = 0;
if (ErrorCount > 20) { ErrorCount = 0; PORTC = 0xAA;
Man_Receive_Init(&PORTD);
}
IdleCount++;
if (IdleCount > 18) { IdleCount = 0; Man_Receive_Init(&PORTD);
}
}while (temp != 0x0B); if (error != 255) {
Lcd_Cmd(LCD_CLEAR); LetterCount = 0;
while (LetterCount < 17) { LetterCount++;
temp = Man_Receive(error); if (error != 255)
Lcd_Chr_Cp(temp) else {
ErrorCount++; break;
}
}
temp = Man_Receive(error); if (temp != 0x0E)
ErrorCount++;
}// end if
}// end while
}//~!
//Error indicator
//Synchronize receiver
//Initialize LCD on PORTB
//Endless loop
//Reset idle counter
//Attempt byte receive
//If there are too many errors
//syncronize the receiver again
//Indicate error
//Synchronize receiver
//If nothing received after some time
//try to synchronize again
//Synchronize receiver
//End of message marker
//If no error then write the message
//Message is 16 chars long
page |
|
222 | MikroElektronika: Development tools - Books - Compilers |
|