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

Driving Seven Segments ( C/C )

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



Joined: 16 Oct 2013
Posts: 7
Location: Sri Lanka

View user's profile Send private message

Driving Seven Segments ( C/C )
PostPosted: Thu Oct 17, 2013 3:36 am     Reply with quote

Dear Friends,
This is a CCS C code for driving two seven segments ( cathode common ).It is counting up to 99.
Code:

#include <16F84A.h>               // Pic Microcontroller (MCU) Select
#fuses NOWDT,HS, NOPUT, NOPROTECT // Fuses
#use delay(clock=20000000)        // Crystal Oscillator Frequency ( 20 MHZ)

   int count;
   int k;
   byte CONST LED_MAP[10] =
   {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67}; // LOOKUP TABLE FOR SSD
   void display_number( int n )

    {

      for(k=0;k<=250;k++)           // Delay ms250
         {
      output_b(LED_MAP[n/10 % 10]); // Left digit (10S) Pin_A4
      output_high(PIN_A4);
      delay_ms(2);
      output_low(PIN_A4);

      output_b(LED_MAP[n%10]);      // Right digit (1S) Pin_A3
      output_high(PIN_A3);
      delay_ms(2);
      output_low(PIN_A3);
         }
     }

      void main()                   // Main block
      {
      int count=1,i;

      while(TRUE)                   // Endless loop
         {
            for(i=0;i<=100;i++);
            {
            display_number(count);
            count = (count==99) ? 1 : count+1;
            }
        }
   }
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Thu Oct 17, 2013 4:16 am     Reply with quote

Why are you posting code from other peoples work?

http://www.ccsinfo.com/forum/viewtopic.php?p=103549
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Oct 17, 2013 6:01 am     Reply with quote

It looks like code from a CCS exercise with additional comments and
changed to another processor, but useful for beginners in any case.
_________________
Google and Forum Search are some of your best tools!!!!
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