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

ds1307 problem

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



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

ds1307 problem
PostPosted: Sat May 01, 2010 12:50 pm     Reply with quote

I'm using the following driver
http://www.ccsinfo.com/forum/viewtopic.php?t=23255

only one problem on it

// Set date for -> 15 June 2005 Tuesday
// Set time for -> 15:20:55
ds1307_set_date_time(15,6,5,2,15,20,55);

I try to set the date in 10may2009 fri 20:30:00
I write
ds1307_set_date_time(10,05,09,05,20,30,00);
But it have an error
Quote:

*** Error 51 "test.c" Line 282(28,29): A numeric expression must appear here

I write (10,05,9,05,20,30,00);
or
(10,05,10,05,20,30,00);
It will be ok

Why 9 can't write 09 in this case?

Thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 01, 2010 10:10 pm     Reply with quote

Quote:

Why 9 can't write 09 in this case?

It's because the number has a leading zero in front of it. In that case,
the compiler interprets it as an Octal number and 09 is a not a valid
Octal number. In the Octal number system, the digit values can only be
from 0 to 7.

Octal isn't used that much anymore, but it is built-in to the compiler.
Each number system is indicated to the compiler by a prefix:

0b = binary
0x = Hexadecimal
0 = Octal
nothing = decimal
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