EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / I have program a DS1302 & AT89C51 C code but the LCD just display 85 : 85 : 85 for the time & it do not run, wad went wrong???

I have program a DS1302 & AT89C51 C code but the LCD just display 85 : 85 : 85 for the time & it do not run, wad went wrong???

|

Microcontroller › 8051 › I have program a DS1302 & AT89C51 C code but the LCD just display 85 : 85 : 85 for the time & it do not run, wad went wrong???

  • This topic has 0 replies, 1 voice, and was last updated 14 years, 7 months ago by Ang wei qiang.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • April 6, 2011 at 8:43 am #851
    Ang wei qiang
    Participant

     

    I have program a DS1302 & At89c51 C code using keil and compile a hex file, den i load the hex file using flip.

    Everything was fine,just that the lCD show 85 : 85 : 85 for the time and the time did not run at all.  What can be the problem??

    Correct me if there is something that im wrong or i need to change. Thx!

     

     

    Below is the code


     

    #include <at89c51xd2.h>
    #include <string.h>
    #include <ds1302.h>

    /*******************************************/
    /* define the button name and the lcd pin  */
    /*******************************************/  
    #define E     P1_2   //LCD E
    #define RW    P1_1   //LCD RW
    #define RS    P1_0   //LCD RS
    #define LCD_DATA  P2   //LCD Data port
    SYSTEMTIME CurrentTime;

    /************************************/
    /*    Function that going to use    */
    /************************************/
    void delay(unsigned int);        //software delay
    void strobe(void);              //write in data
    void LCD_init(void);          //LCD initialisation
    void LCD_print(unsigned char);      //print on LCD
    void LCD_command(unsigned char);   //to set instruction to cursor
    void LCD_TimerDisp();    //Show time

    /*****************/
    /* Main function */
    /*****************/
    void main(void)
    { 
     unsigned char i;

     for(i=0; i<20; i++)
      delay(500);
     
     LCD_init();

     LCD_TimerDisp();
    }

    /************/
    /* Function */
    /************/

    void delay(unsigned int y)
    {
     unsigned int x;
     for(x=0; x<y; x++);
    }

    void strobe()  //write in data
    {
     E = 1;
     delay(500);
     E = 0;
     delay(500);
    }

    void LCD_init()  //LCD initialisation
    {
     RS = 0;
     RW = 0;
     LCD_DATA = 0x38;
     strobe();
     LCD_DATA = 0x0c;
     strobe();
     LCD_DATA = 0x01;
     strobe();
     LCD_DATA = 0x06;
     strobe();
    }

    void LCD_print(unsigned char alpha)  //print on LCD
    {
     RS = 1;     //data type
     RW = 0;     //write enable
     LCD_DATA = alpha; //LCD D0 to D7
     strobe();
    }

    void LCD_command(unsigned char beta) //to set instruction to cursor
    {
     
     RS = 0;     //data type
     RW = 0;     //write enable
     LCD_DATA = beta;
     strobe();
    }

    void LCD_TimerDisp()
    {

     unsigned char alphabet; 

     do
     {
     DS1302_GetTime(&CurrentTime);
     TimeToStr(&CurrentTime);
     LCD_command(0x06);
     LCD_command(0xc0);
     for(alphabet=0; alphabet<9; alphabet++)
     {
      LCD_print(CurrentTime.TimeString[alphabet]);
     }
     delay(300);
     }while(1);
    }

     

     


  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque November 10, 2025
  • Anyone In The US Ordered From AliExpress Recently? November 10, 2025
  • Calculation of A Class amplifier November 10, 2025
  • strange laptop problem November 10, 2025
  • restarting this Christmas project November 10, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise