CODING: 3 digits display.help me 'fix'it

Status
Not open for further replies.

ieda

New Member
hi! can someone help me... i want to display the heart beat on 7 segment display using PIC 16F877..the counter will reset every 60 seconds. and if the counts exceed for example 80, the alam will on... each 7segment display from 0 to 9

my question are:
1)I hv problem on how to display 3 digits..unit -->tens-->hundreds ( my display part)

2) as u can see, i can't organize my coding very well... i dun really understand the c -code format. i dun know how to call my display into my main program..i try but..
in other word, i dun know how to write to make my programmes flow correctly.

3) to detect my sensor :
if (PORTA.F4 ==1) // connect port A to sensor
{
counter =0;
while (1) {
// then i dun know how to 'connect' this part with my display part and my main part


3) i set the timer to reset the counter every 60 seconds, but my lec ask me to just count for 15 seconds and then multiply it by 4..how can i change my programmes


**i already defined all the 7segment interface**




Code:
void main(void){

TRISA=0xFF;  // PORT A as input
TRISB=0;      // PORT B  and PORT D as output
TRISD=0;
TMR1H= 0xFB;
TMR1L= 0x1D;
TICON =0b00101001   //enable Timer 1
PIR1.TMR1IF=0;         // Clear timer 1 interrupt flag
PIE1.TMR1IE=1;         // Enable timer 1 interrupt
INTCON.GIE=1;         //Enable peripheril interrupt




//for display part

void display() {
  if (counter<10); 
                 {
                    case0 ; 
                    display_port = 0b00000011;
                    break;
   
                    case1;
                    display_port = 0b10011111;
                    break:
                     . 
                     .
                     .
                     .// till case9
                 } 
          }


void interrupt() {
      if(PIR1.TMR1IF)
         {
              counter++; 
                TMR1H= 0xFB;
                TMR1L= 0x1D;
                PIR1.TMR1IF=0;

             }
         }        

void alarm() {
 if (counter >80);
  PORTD.F2 = 1;
  delay_ms(1000);
  PORTD.F2 = 0;
}

maybe someone can post any site that can help me with this..example..anything..i look at quite no. of examples, but still dun fully understand...so, i start by doing it part by part.. i'm sorry if this probs only a 'small' prob for u guys...but i already make some effort to do it myself....but still can;t do it correctly... sorry for my eng...
 
Your code makes no sense.

You have,
Code:
  if (counter<10);
This line does nothing as the semi colon terminates the statement. It is more normal to do something like,
Code:
  if (counter<10){
        code to be executed;
  }

You then have case statements without a select statement and your function display never gets called.

This code can't compile without errors. You need to study your notes more.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…