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
You are here: Home / Topics / Problem with 7 segment common Cathode display using C8051F350 Micro Controller

Problem with 7 segment common Cathode display using C8051F350 Micro Controller

|

Microcontroller › 8051 › Problem with 7 segment common Cathode display using C8051F350 Micro Controller

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 5 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • February 22, 2013 at 8:55 am #3850
    Nallapaneni Sai Sankar
    Participant

     

    //


    #include <c8051f350.h>  
    #include<stdio.h>                  // SFR declarations
     
    sbit strobe =P1^1;
    sbit din =P1^0;
    sbit clk =P0^7;/*all chipselects are configured here using sbit;all on P1*/
    sbit cs1 =P1^7;
     
    sbit cy =PSW^7; //ealrier declared as global
    bit temp;
     
    unsigned char dd[10] ={~0x3f,~0x06,~0x5b,~0x4f,~0x66,~0x6d,~0x7d,~0x07,~0x7f,~0x6f};
    unsigned int value;
     
    void delay(void) //creating trouble
    {
     
    TMOD=0x10;
    TL1=0xfb;
    TH1=0xff;
    TR1=1;
    while(TF1==0);
    TF1=0;
    TR1=0;
     
    }
     
    void senddata(unsigned char x)
    {
    unsigned char i;
     
     
     
    din = 0;
    cy = 0;
    strobe = 1;
    temp =0;
    P2 = x;
      for(i=1; i<=8; i++)
    {
    cy=0;
    x= x << 1; //shifting x places the MSB in carryflag(cy);
    temp = cy;
     
    din=temp; //data input to the shift register should be sended serially;
    clk=1;
    clk=0;
    }
     
    strobe=1;
     
    strobe=0;
     
     
    }
     
    void display(char f1)
    {
     
    cs1 = 0x01; //before every data send operation data line should be cleared sending 0xff
    if(value == 10)
    {
    senddata(f1);
    cs1 &=0x00;
    delay();
    cs1 |=0x01;
    }
    else
    {
    senddata(0xff);
    cs1 &=0x00;
    delay();
    cs1 |=0x01;
    if(value == 20)
        value = 0;
    }
     
     
    }
    //


    // MAIN Routine
    //


     
    void led_display() 
    {
     
    while(1)
    {
    value++;
    display(dd[~0x3f]);
    }
     
    }
     
     
     
                                          Thye above is the code that i am using to blink a value in a 7 segment display but what happening is after "2 increments of the 'value' it was getting resetted and the 'value' is becoming zero"  and when i doing on board debugging after 'value' becomes 2 it was automaticalli becoming zero and going into start up code . Help me anyone to solve this .
    February 22, 2013 at 10:40 am #9166
    AJISH ALFRED
    Participant

    Hi Nallapaneni,

    It is obvious that your delay () function is causing trouble. For this particular project precise delay don’t have that much significance.

    Just create a delay using loop waiting technique.

     

    For example;

     

    void delay_us ( int us )

    {

            volatile int uss;

           

            uss = us;

     

            for ( ; uss; uss — );   //assume 1 microsecond for each loop

    }

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

RSS Recent Posts

  • Help identify a part August 15, 2022
  • LM3914 Loading down the reference voltage August 15, 2022
  • Prototype for a detector August 15, 2022
  • CE Transistor Amplifier August 15, 2022
  • Drill speed controller fault August 14, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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