السلام عليكم
البرنامج عمل بنجاح وسبب الرئيسي
قمت بالتعديل بالكود وهي توجد ملاحظه مهمه لم أهتم لها لانه حسب مشروع لازم استلم نبضه البدء هنا لازم أختبر هل يوجد error اذا كان نعم فيوجد عداد يجمع عدد error فأذا وصل عداد error مثلا الى 20 هنا اعمل تزامن من جديد
وهذه ملاحظه من ملف مساعده موجود في مايكروسي وخاصه بالكود مانشيستركود
Note : In case of multiple persistent errors on reception, the user should call this routine once again or Man_Synchro routine to enable synchronization.
ملاحظه توجد ملاحظه مهمه اخرى
Important :
The Manchester receive routines are blocking calls (Man_Receive_Init and Man_Synchro). This means that MCU will wait until the task has been performed (e.g. byte is received, synchronization achieved, etc).
Manchester code library implements time-based activities, so interrupts need to be disabled when using it.
وعندما عملت هذه خطوه ظهرت البيانات على الشاشه
كود:
كود:
while (1) {
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
{
Lcd_Cmd(_LCD_FIRST_ROW); // Move cursor to the 1st row
break; // We got the starting sequence
}
if (error) { // If error occured
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
}
}
}
اذن كود الارسال
كود:
// Manchester module connections
sbit MANTXPIN at RB0_bit;
sbit MANTXPIN_Direction at TRISB0_bit;
// End Manchester module connections
char index, character;
char s1[] = "mikroElektronika";
void main()
{
CMCON = 7; // Configure AN pins as digital I/O
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 first char from string
index = 0; // Initialize index variable
while (character) { // String ends with zero
Man_Send(character); // Send character
Delay_ms(90); // Wait for a while
index++; // Increment index variable
character = s1[index]; // Take next char from string
}
Man_Send(0x0E); // Send "end" byte
Delay_ms(1000);
}
}
اذن كود الارستقبال
كود:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Manchester module connections
sbit MANRXPIN at RC7_bit;
sbit MANRXPIN_Direction at TRISC7_bit;
// End Manchester module connections
char error, ErrorCount, temp;
void main()
{
ErrorCount = 0;
ANSELA = 0; // Configure AN pins as digital I/O
ANSELB = 0;
ANSELC = 0;
ANSELD = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISC.F5 = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Man_Receive_Init(); // Initialize Receiver
while (1) { // Endless loop
while (1) {
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
{
Lcd_Cmd(_LCD_FIRST_ROW); // Move cursor to the 1st row
break; // We got the starting sequence
}
if (error) { // If error occured
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
}
}
}
while (temp != 0x0E) // If "End" byte was received exit do loop
{
temp = Man_Receive(&error); // Attempt byte receive
if (error) { // If error occured
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);
}
}
}