|
|
View previous topic :: View next topic |
Author |
Message |
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
How can i hours and minutes output to a saa1064 |
Posted: Sun Jan 29, 2006 9:23 am |
|
|
I need a routine to output hours and minutes to a saa1064.
void Gettime ()
{
std = read_rtc(0x04)&0x3F; // Stunden vom PCF8583 werden gelesen
min = read_rtc(0x03); // Minuten vom PCF8583 werden gelesen
sek = read_rtc(0x02); // Sekunden vom PCF8583 werden gelesen
time[0]=hexd2decD(sek); // Die aktuellen Sekunden werden in den Array gespeichert
time[1]=hexd2decD(min); // Die aktuellen Minuten werden in den Array gespeichert
time[2]=hexd2decD(std); // Die aktuellen Stunden werden in den Array gespeichert
}
Can someone give me a hint? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jan 29, 2006 9:52 am |
|
|
This sounds like one of those many student assignments that we see here a lot lately.
The SAA1064 is a 4-digit I2C LED driver. From the information you are giving us it doesn't look like you have tried anything to get the device to work. We are willing to help you solve a problem when you are stuck, but we are not going to do your work for you. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Sun Jan 29, 2006 10:06 am |
|
|
ckielstra wrote: | This sounds like one of those many student assignments that we see here a lot lately.
The SAA1064 is a 4-digit I2C LED driver. From the information you are giving us it doesn't look like you have tried anything to get the device to work. We are willing to help you solve a problem when you are stuck, but we are not going to do your work for you. |
Yes, it works now as a counter from 0 to 10000
but i used it now as display unit fro displaying the minutes and hours from the PCF8583 clock chip
But how can i convert this routine to do this?
// Segment table (In hex: d.p.=80,g=40,f=20,e=10,d=08,c=04,b=02,a=01)
byte const seg_table8577[10]=
{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; // 0,1,2,3,4,5,6,7,8,9
void send_saa1064_num(int16 mode,int16 num)
{
int8 j; // Digit index
int8 led_data[4]; // Ram array for segment data
int16 temp16;
// Get led segments for all four digits. Don't need to divide to get units.
temp16 = num;
j = 0;
while (j <= 3)
{
if (j != 0) temp16 /= 10;
led_data[j] = seg_table8577[temp16 %10];
j++;
}
// Do leading zero blanking
if (num<1000) led_data[3] = 0x00;
if (num<100) led_data[2] = 0x00;
if (num<10) led_data[1] = 0x00;
// Add decimal point if required
// led_data[1] |= 0x80;
// Add colon if required
// led_data[0] |= 0x80;
// Send led segments
i2c_start();
i2c_write(SAA1064_WRITE_ADDRESS); // Send SAA1064 address
i2c_write(mode); // Send instruction byte. Zero is control reg.
// Auto increment applies for digit data. Have to send out digits in reverse
// because most significant digit is 1st digit.
for (j=0;j<=3;j++)
i2c_write(led_data[j] & 0xff);
i2c_stop();
} |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jan 29, 2006 4:13 pm |
|
|
Sorry, this is just too easy. You have all the pieces of the puzzle, you only have to put them together.
Hint: Convert the time from the PCF8583 to a 16 bit integer. |
|
|
|
|
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
|