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

Multiplexing

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



Joined: 18 Nov 2016
Posts: 10

View user's profile Send private message MSN Messenger

Multiplexing
PostPosted: Tue Nov 29, 2016 12:26 am     Reply with quote

Can anyone teach how to convert this c code to multiplexing since I used different ports for different 7 segment display.

Code:
#include <18f452.h>
#include <string.h>
#USE DELAY (CLOCK=4000000)
#FUSES XT, NOWDT, NOPROTECT, DEBUG


main(void)
{
int i=0,j=0;
set_tris_b(0xFF);

while(1){

start:if(input(PIN_C0)){   //PIN CO to start program
for(j=0;j<6;j++) {{{      //For the seven segment display for seconds

      output_a(0x3F);                                    //value 0
      delay_us(650);
      output_a(0x06);                  //value 1
      delay_us(650);
      output_a(0x5B);                  //value 2
      delay_us(650);
      output_a(0x4F);                  //value 3
      delay_us(650);
      output_a(0x66);                  //value 4
      delay_us(650);
      output_a(0x6D);                  //value 5
      delay_us(650);
      output_a(0x7D);                  //value 6
      delay_us(650);
      output_a(0x07);                  //value 7
      delay_us(650);
      output_a(0xFF);                  //value 8
      delay_us(650);
      output_a(0x67);                  //value 9
      delay_us (650);
     
}

   switch(j) {              //For the seven segment display for seconds
case 0 :output_d(0x06);
        output_a(0x3F);
break;
case 1 :output_d(0x5B);
      output_a(0x3F);
break;
case 2 :output_d(0x4F);
      output_a(0x3F);
break;
case 3 :output_d(0x66);
      output_a(0x3F);
break;
case 4 :output_d(0x6D);
        output_a(0x3F);
break;
case 5 :output_d(0x3F);
      output_a(0x3F);
break;
   }
}

      if (j==5){                 //For the seven segment display for minutes
      i++;
         switch(i){
            case 1 :output_b(0x06);
               break;
            case 2 :output_b(0x5B);
               break;
            case 3 :output_b(0x4F);
               break;
            case 4 :output_b(0x66);
               break;
            case 5 :output_b(0x6D);
               break;
            case 6 :output_b(0x7D);
               break;
            case 7 :output_b(0x07);   
               break;
            case 8 :output_b(0xFF);
               break;
            case 9 :output_b(0x67);
               i=-1;
            break;
            default: output_b(0x3F);
            }
         }
}

}
 
if (input(PIN_C1)){              //TO reset the stopwatch
      output_b (0x3F) ; //display will show a 0
      output_d (0x3F) ; //display will show a 0
      output_a (0x3F) ; //display will show a 0
           i=0;
           j=0;
      goto start;
      }

}
}

_________________
naren
Mike Walne



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

View user's profile Send private message

Re: Multiplexing
PostPosted: Tue Nov 29, 2016 4:13 am     Reply with quote

naren wrote:
Can anyone teach how to convert this c code to multiplexing since I used different ports for different 7 segment display.

Learn to use the code button, it preserves formatting and should make your code easier to read.

I don't understand your question.

Are you wanting to drive all your LED cathodes from one port and anodes from another?

If so there are loads of examples on this forum and CCS.

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