Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC 16F877A 4 Seven Segment counter Not counting

Status
Not open for further replies.

asking

Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Activity points
3,377
Hello friends,

i have this code from the Mikroc examples EasyPIC5

Code:
#include "Display_utils.h"

char kraj;
unsigned short zz, j, v;
unsigned int i;
unsigned short por[4];

void interrupt() {
  PORTA = 0;
  PORTD = por[v];
  PORTA = zz;              // turn on appropriate 7seg. display
  zz <<= 1;
  if (zz > 8u)
    zz = 1;                // prepare mask for digit
    
  v++ ;
  if (v > 3u)
    v = 0;                 // turn on 1st, turn off 2nd 7seg.
    
  TMR0   =   0;
  INTCON = 0x20;
}//~

void main() {
  OPTION_REG = 0x80;
  j          =   0;
  v          =   0;
  zz         =   1;
  TMR0       =   0;
  INTCON     = 0xA0;       // Disable PEIE,INTE,RBIE,T0IE
  PORTA      =   0;
  TRISA      =   0;
  PORTD      =   0;
  TRISD      =   0;
  
  i          =   1989;
  do {
    j = i / 1000u ;        // prepare digits for diplays
    kraj = mask(j);
    por[3] = kraj;
    j = (char)(i / 100u) % 10u;
    kraj = mask(j);
    por[2] = kraj;
    j = (char)(i / 10u) % 10u;
    kraj = mask(j);
    por[1] = kraj;
    j = i % 10u;
    kraj = mask(j);
    por[0] = kraj;
    
    Delay_ms(1000);
    
    i++ ;                  // increment counter
    if (i > 9999u)
      i = 0;

  } while(1);              // endless loop
}//~

i =1989 it display only 1989 on the display 7 segments... i want it to count.. from 0.....9999 as i++ condition is there but i donno why its not running counter ? please help.....
 

ur program runs only ones,and then stop
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top