قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

أدوات الموضوع

الصورة الرمزية حسن هادي محمود
حسن هادي محمود
:: عضو ذهبي ::
تاريخ التسجيل: Sep 2012
الدولة: العراق /البصره
المشاركات: 2,688
نشاط [ حسن هادي محمود ]
قوة السمعة:135
قديم 06-09-2013, 07:07 AM المشاركة 1   
ha مشكله في بروتوكول I2C Twitter FaceBook Google+



سلام عليكم
توجد مكتبه في مايكروسي وهي تتعامل مع بروتوكول I2C للمايكروكنترولر الذي لايحتوي على بروتوكول I2C
http://img07.arabsh.com/uploads/imag...454a66f702.png
لقد قمت باستخدام هذه مكتبه للمايكرو 16F628A واستخدمت ايسي لغرض عرض وقت ولكن مشكله مايكرو لايعمل اطلاقا
واذا قمت بالغاء كود تعريف

كود:
 Soft_I2C_Init();           // Initialize Soft I2C communication
تظهر رسائل ويعمل مايكرو ولكن لايعرض وقت اي ان بروتوكول I2C لايعمل

ارجو مساعده في حل مشكله

كود:
// Software I2C connections
sbit Soft_I2C_Scl           at RA0_bit;
sbit Soft_I2C_Sda           at RA1_bit;
sbit Soft_I2C_Scl_Direction at TRISA0_bit;
sbit Soft_I2C_Sda_Direction at TRISA1_bit;
// End Software I2C connections

// 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

char seconds, minutes, hours, day, month, year; // Global date/time variables

//--------------------- Reads time and date information from RTC (PCF8583)
void Read_Time() {

  Soft_I2C_Start();               // Issue start signal
  Soft_I2C_Write(0xA0);           // Address PCF8583, see PCF8583 datasheet
  Soft_I2C_Write(2);              // Start from address 2
  Soft_I2C_Start();               // Issue repeated start signal
  Soft_I2C_Write(0xA1);           // Address PCF8583 for reading R/W=1

  seconds = Soft_I2C_Read(1);     // Read seconds byte
  minutes = Soft_I2C_Read(1);     // Read minutes byte
  hours = Soft_I2C_Read(1);       // Read hours byte
  day = Soft_I2C_Read(1);         // Read year/day byte
  month = Soft_I2C_Read(0);       // Read weekday/month byte
  Soft_I2C_Stop();                // Issue stop signal

}

//-------------------- Formats date and time
void Transform_Time() {
  seconds  =  ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F);  // Transform seconds
  minutes  =  ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F);  // Transform months
  hours    =  ((hours & 0xF0)  >> 4)*10  + (hours & 0x0F);    // Transform hours
  year     =   (day & 0xC0) >> 6;                             // Transform year
  day      =  ((day & 0x30) >> 4)*10    + (day & 0x0F);       // Transform day
  month    =  ((month & 0x10)  >> 4)*10 + (month & 0x0F);     // Transform month
}

//-------------------- Output values to LCD
void Display_Time() {

   Lcd_Chr(1, 6, (day / 10)   + 48);    // Print tens digit of day variable
   Lcd_Chr(1, 7, (day % 10)   + 48);    // Print oness digit of day variable
   Lcd_Chr(1, 9, (month / 10) + 48);
   Lcd_Chr(1,10, (month % 10) + 48);
   Lcd_Chr(1,15,  year        + 48);    // Print year variable  (start from year 2010)
   Lcd_Chr(2, 6, (hours / 10)   + 48);
   Lcd_Chr(2, 7, (hours % 10)   + 48);
   Lcd_Chr(2, 9, (minutes / 10) + 48);
   Lcd_Chr(2,10, (minutes % 10) + 48);
   Lcd_Chr(2,12, (seconds / 10) + 48);
   Lcd_Chr(2,13, (seconds % 10) + 48);
}


//------------------ Performs project-wide init
void Init_Main() {
   cmcon=6;
  Lcd_Init();                // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);       // Clear LCD display
  Lcd_Cmd(_LCD_CURSOR_OFF);  // Turn cursor off
  Soft_I2C_Init();           // Initialize Soft I2C communication
  Lcd_Out(1,1,"Date:");      // Prepare and output static text on LCD
  Lcd_Chr(1,8,'.');
  Lcd_Chr(1,11,'.');
  Lcd_Chr(1,16,'.');
  Lcd_Out(2,1,"Time:");
  Lcd_Chr(2,8,':');
  Lcd_Chr(2,11,':');
  Lcd_Out(1,12,"201");       // start from year 2010*/

}

//----------------- Main procedure
void main() {
  Delay_ms(500);

  Init_Main();               // Perform initialization
  delay_ms(3000);

  while (1) {                // Endless loop
    Read_Time();             // Read time from RTC(PCF8583)
    Transform_Time();        // Format date and time
    Display_Time();          // Prepare and display on LCD
  }
}


التعديل الأخير تم بواسطة : حسن هادي محمود بتاريخ 06-09-2013 الساعة 07:11 AM
اعلانات

zamalkawi
:: مهندس جيد ::
تاريخ التسجيل: May 2013
المشاركات: 270
نشاط [ zamalkawi ]
قوة السمعة:0
قديم 06-09-2013, 09:08 AM المشاركة 2   
افتراضي


وفقا لمايكروإلكترونيكا هناك بعض الأشياء يجب مراعاتها، فهل راعيتها جميعا؟ وهي:

Important :

This library implements time-based activities, so interrupts need to be disabled when using Software IC.

All IC Library functions are blocking-call functions (they are waiting for IC clock line to become logical one).

The pins used for the Software IC communication should be connected to the pull-up resistors. Turning off the LEDs connected to these pins may also be required.

Every Software IC library routine has its own counterpart in Hardware IC library, except I2C_Repeated_Start. Soft_I2C_Start is used instead of I2C_Repeated_Start.

Working clock frequency of the Software IC is 20kHz.

اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )
  

الصورة الرمزية حسن هادي محمود
حسن هادي محمود
:: عضو ذهبي ::
تاريخ التسجيل: Sep 2012
الدولة: العراق /البصره
المشاركات: 2,688
نشاط [ حسن هادي محمود ]
قوة السمعة:135
قديم 06-09-2013, 09:29 AM المشاركة 3   
افتراضي


وفقا لمايكروإلكترونيكا هناك بعض الأشياء يجب مراعاتها، فهل راعيتها جميعا؟ وهي:

Important :

This library implements time-based activities, so interrupts need to be disabled when using Software IC.

All IC Library functions are blocking-call functions (they are waiting for IC clock line to become logical one).

The pins used for the Software IC communication should be connected to the pull-up resistors. Turning off the LEDs connected to these pins may also be required.

Every Software IC library routine has its own counterpart in Hardware IC library, except I2C_Repeated_Start. Soft_I2C_Start is used instead of I2C_Repeated_Start.

Working clock frequency of the Software IC is 20kHz.
نعم قرات ذلك قبل تنفيذ دائره
ولكني لم افهم هذه نقطه
Working clock frequency of the Software IC is 20kHz
ارجو توضيح ذلك


الصورة الرمزية حسن هادي محمود
حسن هادي محمود
:: عضو ذهبي ::
تاريخ التسجيل: Sep 2012
الدولة: العراق /البصره
المشاركات: 2,688
نشاط [ حسن هادي محمود ]
قوة السمعة:135
قديم 06-09-2013, 03:34 PM المشاركة 4   
افتراضي


سلام عليكم
توجد مكتبه في مايكروسي وهي تتعامل مع بروتوكول I2C للمايكروكنترولر الذي لايحتوي على بروتوكول I2C
http://img07.arabsh.com/uploads/imag...454a66f702.png
لقد قمت باستخدام هذه مكتبه للمايكرو 16F628A واستخدمت ايسي لغرض عرض وقت ولكن مشكله مايكرو لايعمل اطلاقا
واذا قمت بالغاء كود تعريف

كود:
 Soft_I2C_Init();           // Initialize Soft I2C communication
تظهر رسائل ويعمل مايكرو ولكن لايعرض وقت اي ان بروتوكول I2C لايعمل

ارجو مساعده في حل مشكله

كود:
// Software I2C connections
sbit Soft_I2C_Scl           at RA0_bit;
sbit Soft_I2C_Sda           at RA1_bit;
sbit Soft_I2C_Scl_Direction at TRISA0_bit;
sbit Soft_I2C_Sda_Direction at TRISA1_bit;
// End Software I2C connections

// 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

char seconds, minutes, hours, day, month, year; // Global date/time variables

//--------------------- Reads time and date information from RTC (PCF8583)
void Read_Time() {

  Soft_I2C_Start();               // Issue start signal
  Soft_I2C_Write(0xA0);           // Address PCF8583, see PCF8583 datasheet
  Soft_I2C_Write(2);              // Start from address 2
  Soft_I2C_Start();               // Issue repeated start signal
  Soft_I2C_Write(0xA1);           // Address PCF8583 for reading R/W=1

  seconds = Soft_I2C_Read(1);     // Read seconds byte
  minutes = Soft_I2C_Read(1);     // Read minutes byte
  hours = Soft_I2C_Read(1);       // Read hours byte
  day = Soft_I2C_Read(1);         // Read year/day byte
  month = Soft_I2C_Read(0);       // Read weekday/month byte
  Soft_I2C_Stop();                // Issue stop signal

}

//-------------------- Formats date and time
void Transform_Time() {
  seconds  =  ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F);  // Transform seconds
  minutes  =  ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F);  // Transform months
  hours    =  ((hours & 0xF0)  >> 4)*10  + (hours & 0x0F);    // Transform hours
  year     =   (day & 0xC0) >> 6;                             // Transform year
  day      =  ((day & 0x30) >> 4)*10    + (day & 0x0F);       // Transform day
  month    =  ((month & 0x10)  >> 4)*10 + (month & 0x0F);     // Transform month
}

//-------------------- Output values to LCD
void Display_Time() {

   Lcd_Chr(1, 6, (day / 10)   + 48);    // Print tens digit of day variable
   Lcd_Chr(1, 7, (day % 10)   + 48);    // Print oness digit of day variable
   Lcd_Chr(1, 9, (month / 10) + 48);
   Lcd_Chr(1,10, (month % 10) + 48);
   Lcd_Chr(1,15,  year        + 48);    // Print year variable  (start from year 2010)
   Lcd_Chr(2, 6, (hours / 10)   + 48);
   Lcd_Chr(2, 7, (hours % 10)   + 48);
   Lcd_Chr(2, 9, (minutes / 10) + 48);
   Lcd_Chr(2,10, (minutes % 10) + 48);
   Lcd_Chr(2,12, (seconds / 10) + 48);
   Lcd_Chr(2,13, (seconds % 10) + 48);
}


//------------------ Performs project-wide init
void Init_Main() {
   cmcon=6;
  Lcd_Init();                // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);       // Clear LCD display
  Lcd_Cmd(_LCD_CURSOR_OFF);  // Turn cursor off
  Soft_I2C_Init();           // Initialize Soft I2C communication
  Lcd_Out(1,1,"Date:");      // Prepare and output static text on LCD
  Lcd_Chr(1,8,'.');
  Lcd_Chr(1,11,'.');
  Lcd_Chr(1,16,'.');
  Lcd_Out(2,1,"Time:");
  Lcd_Chr(2,8,':');
  Lcd_Chr(2,11,':');
  Lcd_Out(1,12,"201");       // start from year 2010*/

}

//----------------- Main procedure
void main() {
  Delay_ms(500);

  Init_Main();               // Perform initialization
  delay_ms(3000);

  while (1) {                // Endless loop
    Read_Time();             // Read time from RTC(PCF8583)
    Transform_Time();        // Format date and time
    Display_Time();          // Prepare and display on LCD
  }
}
اين مشكله يااخواني
ارجو مساعده
لماذا لا يتم قراءه التوقيت


الصورة الرمزية Semmoor
Semmoor
:: مهندس متميز ::
تاريخ التسجيل: Oct 2011
المشاركات: 300
نشاط [ Semmoor ]
قوة السمعة:0
قديم 06-09-2013, 11:47 PM المشاركة 5   
افتراضي


لا تضع ;()Soft_I2C_Init في الـ main ولا في ()Init_Main

بس حطه في دالة ()Read_Time في البداية.


الصورة الرمزية حسن هادي محمود
حسن هادي محمود
:: عضو ذهبي ::
تاريخ التسجيل: Sep 2012
الدولة: العراق /البصره
المشاركات: 2,688
نشاط [ حسن هادي محمود ]
قوة السمعة:135
قديم 07-09-2013, 02:22 AM المشاركة 6   
win


لا تضع ;()Soft_I2C_Init في الـ main ولا في ()Init_Main

بس حطه في دالة ()Read_Time في البداية.
شكرا جزيلا اخي كريم
وضعت تعريف ;()Soft_I2C_Init في دالة ()Read_Time وشتغلت تمام
تسلم اخي


الصورة الرمزية Semmoor
Semmoor
:: مهندس متميز ::
تاريخ التسجيل: Oct 2011
المشاركات: 300
نشاط [ Semmoor ]
قوة السمعة:0
قديم 07-09-2013, 10:24 AM المشاركة 7   
افتراضي


تمام.......


fawzy73
:: مهندس متواجد ::
تاريخ التسجيل: Dec 2008
المشاركات: 93
نشاط [ fawzy73 ]
قوة السمعة:0
قديم 07-12-2013, 12:47 PM المشاركة 8   
افتراضي


السلام عليكم ورحمة الله

اخي العزيز حسن

حاولت كتابة الكود مع التعديل ولكن لم ينجح معي

ارجو المساعدة منكم في الكود الصح
شكرا

إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 07:38 PM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2025