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

Bit of a 7 Segment and DS1305 Code Problem

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

Bit of a 7 Segment and DS1305 Code Problem
PostPosted: Tue Jun 06, 2006 1:39 pm     Reply with quote

Hi Every One .

I have a PIC 16F877A Board with 74595 thats connected to Four 7 Segment leds

And a DS1305 thats hard wired to the PIC .

Both these are working fine .

My Problem is I want to display the time output from the DS1305 on the Four seven segment leds

At the moment all I am getting is seconds .displayed and these reset to zero after counting up to 60 .

Any help to a novice will be greatly appreciated .


Code:
#fuses HS,NOLVP,NOWDT,PUT

#use rs232(debugger, xmit=PIN_B5, rcv=PIN_B5)
#include<stdlib.h>
#include<input.c>

#define RTC_SCLK  PIN_D0
#define RTC_IO    PIN_D1
#define RTC_RST   PIN_D6

#define EXP_OUT_DO        PIN_D1
#define EXP_OUT_CLOCK     PIN_D0
#define EXP_OUT_ENABLE    PIN_D2
#define NUMBER_OF_74595 4
#include <74595.c>
#include<ds1305.c>

const byte number [10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x7F,0x6F};
               

void led_display_number(long int d)
{

   int time_array[4];

   time_array[0]=number[d/1000%10];
   time_array[1]=number[d/10%10];
   time_array[2]=number[d/10%10];
   time_array[3]=number[d%10];


   write_expanded_outputs(time_array);
   output_low(EXP_OUT_ENABLE);

}


   void main()

         {         
               int     hour, minute,second;

               output_low(PIN_D6);

               rtc_init();

            while(true)
            {         rtc_get_time(hour,minute,second);

                       printf(" \r\n%u:%02u: %02u",hour,minute,second);

                     led_display_number(second);
               
               
            }

         }

ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 3:21 pm     Reply with quote

Code:
                    led_display_number(second);
You are only passing the seconds to the display function. With computers you never get more than you put into them.

To display hours, minutes and seconds you need at least a 6-digit display. You only have four digits. How do you want to map the time digits to this display?
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 3:56 pm     Reply with quote

Yes you are right . In thats case i can only disply minutes and hours . . but with display led function i can only display . one at a time . how would i chage this function to display minutes and hours . thanks for your help
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jun 07, 2006 1:01 am     Reply with quote

I get the feeling this is a school assignment and that you have no clue as to what you are doing. The program has some loose ends and contains different programming styles showing me this is a copy/paste action. Everything you need is shown in the posted program. Was it you who designed this program then it would be only a small step to modify it and display hours&minutes.

If you have problems in understanding the program then I want to help, but I refuse to do your homework.
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