CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to fix 7 Segment multiplex blink ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mmc01



Joined: 16 Jun 2010
Posts: 31

View user's profile Send private message

How to fix 7 Segment multiplex blink ?
PostPosted: Sat Jun 07, 2014 9:52 am     Reply with quote

I connect 7 Segment Anode 2 Digits to 16F887 by multiplex. The 7 Segment always blink. I reduce delay in code but it blink yet. How to fix it ?

Code:
#include <16F887.h>
#fuses HS
#fuses NOLVP
#fuses NOWDT
#fuses NOPROTECT
#use delay(clock = 4000000)

#define LED_DSP(x)   OUTPUT_C(x)

char dt1,dt2;        // delay time
int i=0;

     // LED Number Cathode
/*char const  LED_NUM[10] = {0x3F,0x06, 0x5B, 0x4F,  //0,1,2,3
                           0x66, 0x6D, 0x7D,  //4,5,6
                           0x07, 0x7F, 0x6F,  //7,8,9
                          };
*/

   //LED Number Anode
char const  LED_NUM[10] = {0x40,0x79, 0x24, 0x30,  //0,1,2,3
                           0x19, 0x12, 0x02,  //4,5,6
                           0x78, 0x00, 0x10,  //7,8,9
                          };

//-------------------------------------------------------Dispaly Digit1
void dsp_digit1(char n) {
  output_b(0x05);
  LED_DSP(n);
  delay_ms(2-dt1-dt2);   // delay
}

//-------------------------------------------------------Dispaly Digit2
void dsp_digit2(char n) {
  output_b(0x03);
  LED_DSP(n);
  delay_ms(dt1);        // delay
}
     
void main (void)
{     
   while(1)
   { 
         i++;     
         dsp_digit1(LED_NUM[i/10]);
         delay_ms(50);
         dsp_digit2(LED_NUM);
         delay_ms(50);

     if(i>99){
         i = 0;
      }
   }
     
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Sat Jun 07, 2014 12:14 pm     Reply with quote

What if anything is putting a value into dt1, and dt2?.

The line:

delay_ms(2-dt1-dt2); // delay

Will overflow, if these are anything other than '0' or '1'. They'll wake up probably containing 255. integers are unsigned by default, so the value would wrap and could give silly long delays.
Get rid of both these delays. You already have fixed digit delays in the outer loop.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Jun 07, 2014 3:06 pm     Reply with quote

What characters is your display actually showing?
What are you wanting your display to show?

Your code is very confused.

Mike
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group