Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16F877A 7 Segment Counter, Not Counting

Status
Not open for further replies.

asking

New Member
Hello friends,

Here's the code for the 7 segment counter, But its not counting....can u tell me reason why its showing 0000 on display....please help me...

Code:
#include "Display_utils.h"

char kraj;
unsigned short zz, j, v;
unsigned int i;
unsigned int k;
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          =   k;
  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);

if (i==k)
{
k=0,k<9999u,k++;
k>9999u,k=0;
Delay_ms(1);
}

  } while(1);              // endless loop
}//~
 
Guyz...i got it...:) it was WDTE was Enabled. Watchdog timer was enable so it was Resseting processes every time it tries to count :)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top