View previous topic :: View next topic |
Author |
Message |
deltatech
Joined: 22 Apr 2006 Posts: 87
|
Bit of a 7 Segment and DS1305 Code Problem |
Posted: Tue Jun 06, 2006 1:39 pm |
|
|
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
|
|
Posted: Tue Jun 06, 2006 3:21 pm |
|
|
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
|
|
Posted: Tue Jun 06, 2006 3:56 pm |
|
|
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
|
|
Posted: Wed Jun 07, 2006 1:01 am |
|
|
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. |
|
|
|