RTC 12C887 Issue with P89V51RD2

Discussion in 'Embedded Systems and Microcontrollers' started by scintrillating, Feb 11, 2012.

  1. scintrillating

    Thread Starter New Member

    Dec 30, 2011
    5
    0
    I have Interfaced 12C887 with P89V51RD2 but the time update does not occur. However the same code when burned in AT89C51, works perfectly...But due to memory restrictions of 4Kb in the Later, we have to use the former. Please help me out on this issue, ASAP!

    The Code is :

    Code ( (Unknown Language)):
    1.  
    2. #include <P89V51Rx2.H>
    3. #include<ABSACC.h>
    4.  
    5. #define port P3
    6. #define lcd_dataport P2  // lcd_dataport for lcd
    7. #define keypad P1  // Port for keypadpad
    8. #define timeport P0 // Port for RTC
    9.  
    10. sbit rs = port^0;
    11. sbit rw = port^1;
    12. sbit en = port^5;
    13.  
    14. int hr, min, sec;
    15.  
    16. void delay(unsigned int msec) //Time delay function
    17. {
    18. int i,j ;
    19. for(i=0;i<msec;i++)
    20. for(j=0;j<1275;j++);
    21. }
    22.  
    23. void lcdcmd(unsigned char item) //Function to send command to LCD
    24. {
    25. lcd_dataport = item;
    26. rs=0;
    27. rw=0;
    28. en=1;
    29. delay(1);
    30. en=0;
    31. return;
    32. }
    33.  
    34. void lcddata(unsigned char item) //Funtion to send data on LCD
    35. {
    36. lcd_dataport = item;
    37. rs=1;
    38. rw=0;
    39. en=1;
    40. delay(1);
    41. en=0;
    42. }
    43.  
    44. void lcddata_string(unsigned char *str) // Function to send string on LCD
    45. {
    46. int i=0;
    47. while(str[i]!='\0')
    48. {
    49. lcddata(str[i]);
    50. i++;
    51. delay(1);
    52. }
    53. }
    54.  
    55. void lcd(unsigned char str[10])  // Funtion display string on LCD
    56. {
    57. lcdcmd(0x38);
    58. lcdcmd(0x0C);
    59. lcdcmd(0x01);
    60. lcdcmd(0x80);
    61. lcddata_string(str);
    62. }
    63.  
    64. void rtc_read(unsigned char item)
    65. {
    66. timeport = item;
    67. }
    68.  
    69. void rtc_write(unsigned char item)
    70. {
    71. timeport = item;
    72. }
    73.  
    74. void bcdconv(unsigned char mybyte)
    75. {
    76. unsigned char x,y;
    77. x=mybyte&0x0F;
    78. x=x|0x30;
    79. y=mybyte&0xF0;
    80. y=y>>4;
    81. y=y|0x30;
    82. lcddata(y);
    83. lcddata(x);
    84. }
    85.  
    86. void main()
    87. {
    88. delay(220);
    89. XBYTE[11]=0x82;
    90. XBYTE[4]=0x15;
    91. XBYTE[2]=0x55;
    92. XBYTE[0]=0x00;
    93. XBYTE[11]=0x02;
    94. lcd("TIME:");
    95. while(1)
    96. {
    97. lcdcmd(0x88);
    98. rtc_read(0x00);
    99. }
    100. }
    101. [/i][/i]
     
    Last edited by a moderator: Feb 11, 2012
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    Seriously, are you asking why working code for an Atmel device does not work on a Microchip device?
     
  3. Santosh_16k

    New Member

    Aug 19, 2011
    19
    0
    ErnieM, can u explain y is this happening?
     
Loading...