Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

RTC clock address selecting

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 168
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Wed Aug 12, 2015 1:35 pm    Post subject: RTC clock address selecting Reply with quote

Hi
I'm busy changing one of my projects from a DS1307 to a DS3231 RTC. Im using the SWQ pin to drive a INT in my program.

My old for the DS1307 code is

Code:

'Setup the module so SQW outpin triggers at one sec
I2cstart                                                                        'Setup the SQW pin for 1 pulse/sec
   I2cwbyte Ds1307w                                                      'DS1307 write address
   I2cwbyte 7                                                                 'Data to go to the control register 7
   I2cwbyte &B00010000                                                          'set
I2cstop
 


my new code for the DS3231 is

Code:

'Setup the module so SQW outpin triggers at one sec
I2cstart                                                                        'Setup the SQW pin for 1 pulse/sec
   I2cwbyte Ds1307w                                                             'Ds1307w
   I2cwbyte &HE                                                                 'Data to go to the control register 7
   I2cwbyte &B01000000                                                          'set
I2cstop
 


this works fine with no worries


My question is
What does "I2cwbyte Ds1307w" do? I know it has something to do with the I2C rtc address of the RTC. If i change the code to I2cwbyte Ds3231w it fails to compile. Where does Bascom look up the information on Ds1307w to get the address from. I want to change it so my code matched the RTC i'm now using.

Thanks
Snow

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Aug 12, 2015 6:24 pm    Post subject: ds1307R and DS1307W constants... Reply with quote

Think there are two constants in your code

DS1307W and DS1307R

They have the read and write address of the DS1307

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 168
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Thu Aug 13, 2015 12:37 am    Post subject: Reply with quote

Hi Ben
Yes you're right there are 2 constants for the 1307 R/W. Where is the address for that those constants stored in bascom?. I want to add the DS13231 RTC to the list. I know the addresses are the same as my code works but i would like to add this RTC to it so my code looks correct ETC and possibly add other external devices as well at some stage.

is it in some lib file??


Thanks
Snow
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Thu Aug 13, 2015 1:11 am    Post subject: Constants in flash Reply with quote

Constants are stored in flash.

It should be somewhere in you program.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
snow

Bascom Member



Joined: 28 Jun 2005
Posts: 168
Location: Ashburton / Mid Canterbury / New Zealand

newzealand.gif
PostPosted: Thu Aug 13, 2015 1:34 am    Post subject: Reply with quote

Sorry yes your right Embarassed

I couldn't see the wood for the trees.
In the C:\Program Files\MCS Electronics\BASCOM-AVR\LIB folder there is a few ds1307.lib files. What do they do??

ds1307clock.lib
ds1307clock_ger.lib


Snow
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum