Discussion forum for the BasicX family of microcontroller chips.
Keeping track of date and time - David Sousa Mendes - Oct 6 12:09:59 2009
Hello fellows
On an old thread, someone suggested the use of DS1302 as an external RTC...
Is there any new/better chip on the market or do you still think this is
the best way to keep track of date and time?
Regards
David M.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - ian_casey02 - Oct 6 13:36:29 2009
David,
I have been using the DS1306 for about 6 years, not sure of the difference from the DS1302
but I can run it on the SPI bus and use a supercap to keep the timer running 2-3 weeks
after the power is off. I think it's almost identical code apart from the command to turn
on the charger for the supercap.
Ian
--- In b...@yahoogroups.com, David Sousa Mendes
wrote:
>
> Hello fellows
> On an old thread, someone suggested the use of DS1302 as an external RTC...
> Is there any new/better chip on the market or do you still think this is
> the best way to keep track of date and time?
>
> Regards
>
> David M.
>
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )RE: Keeping track of date and time - bipsnmsw - Oct 7 9:15:30 2009
Try PMB-248 GPS from Parallax. It gives you UTC without being in line of
sight with satellites.
http://www.parallax.com/tabid/768/txtSearch/pmb-248/List/0/SortField/4/Defau
lt.aspx
From: b...@yahoogroups.com [mailto:b...@yahoogroups.com] On Behalf Of
David Sousa Mendes
Sent: Tuesday, October 06, 2009 10:10 AM
To: b...@yahoogroups.com
Subject: [BasicX] Keeping track of date and time
Hello fellows
On an old thread, someone suggested the use of DS1302 as an external RTC...
Is there any new/better chip on the market or do you still think this is
the best way to keep track of date and time?
Regards
David M.
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - David Sousa Mendes - Oct 7 9:35:59 2009
Thanks j...@bipsnm.com, but this application will be deployed inside a
cave, so, it will never be in line of sight with satellites... Otherwise
it could be a good option...
Ian, concerning your DS1306:
1 - What is the capacity of your "supercap"?
2 - Do you need an external oscilator, crystal, or whatever? Where can
we buy such a thing?
3 - Do you think you could provide your source code?
Cheers
David
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Patrick - Oct 7 13:05:55 2009
Hello,
I had a quick look of the datasheet of the DS1006 and it does not look very easy to use
this IC.
Can you tell me from where you read the data (serial data) , what you have to do to read
the data.
It the IC aware of the today date or do we have to dop something to it to write the real
date.
What about IC which receive the date from a radio transmiter ?
Thanks and best regards.
Patrick.
--- In b...@yahoogroups.com, David Sousa Mendes
wrote:
>
> Thanks john@..., but this application will be deployed inside a
> cave, so, it will never be in line of sight with satellites... Otherwise
> it could be a good option...
>
> Ian, concerning your DS1306:
> 1 - What is the capacity of your "supercap"?
> 2 - Do you need an external oscilator, crystal, or whatever? Where can
> we buy such a thing?
> 3 - Do you think you could provide your source code?
>
> Cheers
>
> David
>
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: Keeping track of date and time - David Sousa Mendes - Oct 7 13:19:44 2009
Patrick, my knowledge on the subject is still very scarse...
Regarding radio transmitions, and since I will deploy my system on a
cave, I won't be able to used it neither..
Regards
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - ian_casey02 - Oct 7 14:35:31 2009
David,
> 1 - What is the capacity of your "supercap"?
0.22F part # GC5.5V0.22F
> 2 - Do you need an external oscilator, crystal, or whatever? Where can
> we buy such a thing?
yes I use an external crystal 32.768k with a couple of 18pf caps.
I get all this from Digikey in the US
> 3 - Do you think you could provide your source code?
sure but I will need a couple of days to dig out all the relevant stuff.
Warning: there is something in the SPICmd that sets the pin state opposite from what the
CE line of the DS1306 wants. I ended up using a 2N3904 to get the correct input. I did all
this 6 years ago, and I don't remember all the reasons, but I have an ugly mod on the
back of my board.
Ian
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Re: Keeping track of date and time - David Sousa Mendes - Oct 7 18:42:34 2009
Thanks, Ian
When you have the code, I'll be happy to see it!
Sorry for my bad english, but what do you mean by :
" I have an ugly mod on the back of my board."?
Regards
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - ian_casey02 - Oct 9 15:21:40 2009
David,
mod - hardware modification. Sorry
--- In b...@yahoogroups.com, David Sousa Mendes
wrote:
>
> Thanks, Ian
> When you have the code, I'll be happy to see it!
> Sorry for my bad english, but what do you mean by :
> " I have an ugly mod on the back of my board."?
>
> Regards
>
> David M.
>
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: Keeping track of date and time - David Sousa Mendes - Oct 13 11:40:20 2009
Hello fellows
I'm still trying to choose the best MAXIM's RTC for my application...
But in their site:
http://para.maxim-ic.com/en/index.mvp?tree=timers
One can see that they have RTC with several serial protocols: I2C, SPI,
3-Wire, 1-Wire.
I'm a bit lost here...
1 - Which of these protocols can be used with BasicX24?
2 - Can I have 2 SPI chips communicating at the same time with the BasicX24?
3 - Is the 3-Wire protocol the normal serial protocol one uses to
communicate, for instance with a serial LCD?
Cheers
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Re: Keeping track of date and time - Tom Becker - Oct 13 12:06:02 2009
> ... I2C, SPI, 3-Wire, 1-Wire.
All of those protocols can be used, each very differently. SPI is
implemented in hardware; the others must be bit-banged in code.
Examples of each except, perhaps, 1-wire, are in the group's Files
section, I believe.
Four SPI devices can be connected simultaneously, sharing MOSI, MISO,
SCK, Vcc and ground, and each device needs its own /CS pin. SPI is fast
and easy in code, using SPICmd(); it would be my preference. Many
others, though, seem to prefer I2C.
Here's a comparison: http://pdfserv.maxim-ic.com/en/an/AN619.pdf
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: Re: Keeping track of date and time - "Harry J. White" - Oct 13 13:09:25 2009
David,
Out of the three protocols I have used everything but the 1 wire. I like
the I2c (Personal pref) mostly
because you can use the same two wires to communicate with several low
bandwidth devices. I currently
use it with an LCD, temperature monitor and static ram.
As far as two SPI chips communicating at the same time...do you mean on the
same set of wires or actually
communicating simultaineously. In the first case I believe you will need
one additional wire and in the second
you will need to run some sort of multi-tasking or a multi-processor like
the Parallax Propeller.
Harry
_____
From: b...@yahoogroups.com [mailto:b...@yahoogroups.com] On Behalf Of
David Sousa Mendes
Sent: Tuesday, October 13, 2009 11:40 AM
To: b...@yahoogroups.com
Subject: Re: [BasicX] Re: Keeping track of date and time
Hello fellows
I'm still trying to choose the best MAXIM's RTC for my application...
But in their site:
http://para.
maxim-ic.com/en/index.mvp?tree=timers
One can see that they have RTC with several serial protocols: I2C, SPI,
3-Wire, 1-Wire.
I'm a bit lost here...
1 - Which of these protocols can be used with BasicX24?
2 - Can I have 2 SPI chips communicating at the same time with the BasicX24?
3 - Is the 3-Wire protocol the normal serial protocol one uses to
communicate, for instance with a serial LCD?
Cheers
David M.
Dynatest Confidential
Note: This message and any attachment hereto is intended solely for the use of
the designated recipient(s) and their appointed delegates and may contain
confidential information. Any unauthorized use, disclosure, copying, or
distribution of its contents is strictly prohibited. If you have received this
message in error, please destroy it and advise the sender immediately by phone,
email, or fax. Thank you for your cooperation
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Keeping track of date and time - dani...@amberjacksolutions.com - Oct 16 10:34:08 2009
Hello everybody!
I was thinking about using the quartz crystal from a damaged bx24 on a RTC DS1302.
Does anyone know if it is compatible?
Regards,
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Re: Keeping track of date and time - Tom Becker - Oct 16 12:01:32 2009
> ... compatible?
No. The DS1302 - and most inexpensive timekeeping devices, like your
watch, a digital stopwatch, clock radio, some wireless phones, etc. -
use a 32.768Hz crystal that can be easily divided to 1Hz. The BX-24
crystal is 7.3728MHz, which is a common convenient frequency to derive
serial communication rates.
There is also a small cylindrical 32.768kHz crystal on many PC
motherboards, new and old; search through your junkbox and you're likely
to find one.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Re: Keeping track of date and time - Tom Becker - Oct 16 12:58:25 2009
> ... 32.768Hz...
Should be 32.768kHz.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 24 14:05:32 2009
Hello
I'm trying to connect a RTC (DS1305) to BX24 using SPI protocol.
Does anyone know if any I/O port from the basicx can be configured to
Serial In, Serial Out and SCLK?
And how to we say to the program which pins are we using for each?
(apart from the CE pin which is defined in OpenSPI procedure)
Thanx
David M.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 24 14:58:34 2009
> ... if any I/O port from the basicx can be configured to Serial In,
Serial Out and SCLK?
No, MISO, MOSI and SCK are fixed and are available on the edge of the
BX-24 module, the center three of seven holes. On the BX-24p schematic
they are on connector H8.
Tom
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 24 19:12:40 2009
Hum...
And how do I physically connect what so ever to those opened holes?
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 24 21:10:42 2009
> ...how do I physically connect...
I've used a few methods, but the most simple is to simply solder three
small wires to the holes.
You can also, though, use headers to connect to header pins like this:
http://rightime.com/images/DSCN0260a.JPG , or add socket pins like this:
http://rightime.com/images/DSCN0263a.JPG . The latter must be mated with
a socket to suit, perhaps a subset of this:
http://groups.yahoo.com/group/basicx/photos/album/1482585026/pic/33080814/view?picmode=&mode=tn&order=ordinal&start=1&count=20&dir=asc
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Advantages of BX24 over ZBASIC - David Sousa Mendes - Oct 25 16:42:08 2009
Hello
I've been working for several years with basicx24...
I have even been persuaded to move to zbasic microcontrolers and heard
their version of the advantages of their microcontrolers...
So, I was wondering, maybe it would be good to hear your version of the
story, or putting it this way:
What advantages can bx24 have over other similar microcontrolers like
Zbasic?
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 28 11:45:51 2009
Hello
As Tom Becker suggested, I connected my SPI wires to connector H8...
I'm using the following lines:
MOSI - connected to DataIn of my RTC
MISO - connected to DataOut of my RTC
SCLK - connected to SCLK
VCC - connected to Vccc1
Gnd - connected to GROUND
My problem is that, every time I try to download my program into the BX,
with my wires connected to H8, the download stucks and I get the error:
"Error verifying external EEPROM "
If I disconnect H8, no problems appear...
Any ideas?
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 28 12:57:57 2009
> ...
MOSI - connected to DataIn of my RTC
MISO - connected to DataOut of my RTC
SCLK - connected to SCLK
VCC - connected to Vccc1
Gnd - connected to GROUND
... "Error verifying external EEPROM "
You also need a /CS line to a BX-24 pin, which should also have a pullup
resistor to Vcc. During processor Reset, all pins float so the RTC /CS
state will be uncertain withoutthe pullup. Since the processor uses SPI
to access the program code in EEPROM, your RTC will interfere unless its
/CS state is proper.
You're close.
Tom
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 29 9:18:40 2009
Tom,
On 1305 datasheet, I can't see any CS pin...
Do you think it could be the CE (chip enable) pin?
Thanx
David M.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 29 10:42:52 2009
> ... the CE (chip enable) pin?
CE (chip enable), CS (chip select), SS (slave select) are all usually
synonymous.
Yes, although it is active-high, not active-low, which is the convention
in my experience - and what the BX-24 expects. You'll need, then, to
invert \CS from the processor.
You can use any inverting logic device like a 74n04, or a transistor
configured as an inverter (typically two resistors and an NPN but, since
the CE pin has an internal pulldown, just a single base resistor on a
PNP, emitter to Vcc, collector to CE, should also work), between the /CS
pin you select on the BX-24 and the CE input of the RTC. You should
still put a pullup resistor between your selected /CS pin and Vcc to
avoid the Reset concern.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 30 12:18:49 2009
Tom, problems that have been solved so far:
1- Bx does not stuck anymore while downloading (since I put the pullup
resistor in CS pin)
2 - BX's CS is active low. I'm now communicating with max146, which is
also active low, so no need to invert logic using a transistor or a 74N04.
I'm trying to communicate with max146 instead of DS1305 because I'm more
familiar with it...
Now the problem is that I only receive bytes containing zeros...
My code is:
dim sent_bytes(1 to 3)as byte
dim received_bytes(1 to 3) as byte
sent_bytes(1)=bx1000_1111
sent_bytes(2)=bx0000_0000
sent_bytes(3)=bx0000_0000
do
Call SPICmd(1,3,sent_bytes,3,received_bytes)
debug.print "1º:"; CStr(received_bytes(1))
debug.print "2º:"; CStr(received_bytes(2))
debug.print "3º:"; CStr(received_bytes(3))
call delay (1.0)
loop
Any ideas?
How should I configure the initial state of CS pin? Tristate, Pullup,
Output_low, Output_high?
Thanx again for your help
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 30 12:53:34 2009
No OpenSPI()? The specified /CS pin will be automatically configured by it.
Tom
> dim sent_bytes(1 to 3)as byte
> dim received_bytes(1 to 3) as byte
> sent_bytes(1)=bx1000_1111
> sent_bytes(2)=bx0000_0000
> sent_bytes(3)=bx0000_0000
> do
> Call SPICmd(1,3,sent_bytes,3,received_bytes)
> debug.print "1º:"; CStr(received_bytes(1))
> debug.print "2º:"; CStr(received_bytes(2))
> debug.print "3º:"; CStr(received_bytes(3))
> call delay (1.0)
> loop
>
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Oct 30 13:09:20 2009
Sorry, Tom, didn't give you all the code to make it simpler...
here goes:
Option Explicit
public Channel As Byte
Public Sub Main()
call abre_spi()
call mede_ADC()
End Sub
'__________________________________________________________________________________
Public sub mede_ADC()
dim sent_bytes(1 to 3)as byte
dim received_bytes(1 to 3) as byte
sent_bytes(1)=bx1000_1111 ' para channel 0
sent_bytes(2)=bx0000_0000
sent_bytes(3)=bx0000_0000
do
Call SPICmd(1,3,sent_bytes,3,received_bytes)
debug.print "1º:"; CStr(received_bytes(1))
debug.print "2º:"; CStr(received_bytes(2))
debug.print "3º:"; CStr(received_bytes(3))
call delay (1.0)
loop
End sub
'_____________________________________________________________________________________
public sub abre_spi()
Dim ChipSelectPin As Byte
Dim LSBFirst As Boolean
Dim ClockPolarity As Boolean
Dim ClockPhase As Boolean
Channel = 1
ChipSelectPin = 13
LSBFirst = False
ClockPolarity = False
ClockPhase = False
Const SPIRateDiv4 As Byte = bx0000_0000 ' Clock speed = f/4
Const SPIRateDiv16 As Byte = bx0000_0001 ' Clock speed = f/16
Const SPIRateDiv64 As Byte = bx0000_0010 ' Clock speed = f/64
Const SPIRateDiv128 As Byte = bx0000_0011 ' Clock speed = f/128
Const ClockRateSelect As Byte= SPIRateDiv128
' See Atmel documentation for these bits.
Const DORD As Byte = bx0010_0000 ' Data order, LSB first.
Const CPOL As Byte = bx0000_1000 ' Clock polarity, SCK high when idle.
Const CPHA As Byte = bx0000_0100 ' Clock phase.
Dim SetupByte As Byte
' Safety clamp.
If (Channel < 1) Then
Channel = 1
ElseIf (Channel > 4) Then
Channel = 4
End If
SetupByte = ClockRateSelect
If (LSBFirst) Then
SetupByte = SetupByte Or DORD
End If
If (ClockPolarity) Then
SetupByte = SetupByte Or CPOL
End If
If (ClockPhase) Then
SetupByte = SetupByte Or CPHA
End If
Call OpenSPI(Channel, SetupByte, ChipSelectPin)
End sub
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Oct 30 14:32:42 2009
Looking quickly, I don't see an obvious problem. I posted a simple
two-transistor SPI loopback drawing (actually, a tristate non-inverting
buffer, enabled by /CS, is simpler if you happen to have one) some time
ago. The loopback should simply echo your sent data. If it works, the
problem is probably with the device.
If this link doesn't work, look for it in
http://tech.groups.yahoo.com/group/basicx/files/Datasheets-Appnotes-Examples-Drawings/Comm/SPI/SPI_Loopback.JPG
.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 3 10:40:17 2009
Hello
Eventough it still needs some tunning, I'm being able to receive
valuable data from the max146...
One question: how should the CS pin be configured? Tristate, Pullup,
Output_Low, Output_High?
Reg
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 3 11:33:50 2009
And yet another question:
In my code:
Call SPICmd(1,1,sent_bytes(1),1,received_bytes(1))
Call SPICmd(1,1,sent_bytes(2),1,received_bytes(2))
Call SPICmd(1,1,sent_bytes(3),1,received_bytes(3))
debug.print CStr(received_bytes(1)) ; ";" ; CStr(received_bytes(2)); ";"
; CStr(received_bytes(3))
The result of the ADC conversion is being sent on the first 2 received
bytes whereas it should be sent on the last 2 received bytes...
Any ideas, on why this is happening?
Reg
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 3 15:26:37 2009
> ... how should the CS pin be configured?
OpenSPI will configure the /CS pin high. It's state before that should
be either untouched (since a processor Reset sets all pins to
InputTristate) or, if you like, you may set the pin to any state except
Low, which will likely cause the SPI device to interfere with code
execution.
Assuming you have an SPI device connected, with its /CS on pin 12, you
can test this easily:
Sub Main()
call sleep(1.0)
' call PutPin(12, bxOutputLow) ' will probably crash the machine
here, no flashing LED
call OpenSPI(1, 0, 12) ' pin 12 set high by Open
do ' flash LED
call PutPin(25, bxOutputLow)
call sleep(0.1)
call PutPin(25, bxOutputHigh)
call sleep(0.1)
loop
End Sub
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 3 15:29:46 2009
> ... how should the CS pin be configured?
OpenSPI will configure the /CS pin high. Its state before that should
be either untouched (since a processor Reset sets all pins to
InputTristate) or, if you like, you may set the pin to any state except
Low, which will likely cause the SPI device to interfere with code
execution.
Assuming you have an SPI device connected, with its /CS on pin 12, you
can test this easily:
Sub Main()
call sleep(1.0)
' call PutPin(12, bxOutputLow) ' will probably crash the machine
here, no flashing LED
call OpenSPI(1, 0, 12) ' pin 12 set high by Open
do ' flash LED
call PutPin(25, bxOutputLow)
call sleep(0.1)
call PutPin(25, bxOutputHigh)
call sleep(0.1)
loop
End Sub
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - David Sousa Mendes - Nov 4 11:29:18 2009
Thanx, Tom!
My next step is to try to configure the BX to communicate with max1302
via 3-wire protocol...
1 - What should I change on my pin configuration on the BX24 side?
2 - Should I still use OpenSPI and SPICmd commands?
Reg
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 4 12:50:07 2009
> ... 1 - What should I change on my pin configuration on the BX24 side?
2 - Should I still use OpenSPI and SPICmd commands?
If, by "3-wire protocol" you mean SPI, if you are currently successful
with the max146, I see no reason to change anything except the data you
send to control the device, and the handling and interpretation of the
resulting data.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 5 5:27:09 2009
But on the max1302 side I only have the following pins for communication:
SCLK, I/O and CE
What should I connect to I/O? Both MISO and MOSI? Without external
components such as diodes or resistors?
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 5 6:51:07 2009
> ... SCLK, I/O and CE...
Are we looking at the same part?
The Maxim Max1302 shows Din, Dout, SClk, and /CS.
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4746
Tom
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 5 7:40:48 2009
No, sorry, the CORRECT part number is maxim's DS1302:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2685
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 5 10:50:13 2009
> ... DS1302...
Ah; you did say 3-wire and, you're right, that's not an SPI interface
device. You'd have better success, I think, using ShiftIn() and
ShiftOut() with it.
Somewhere up the thread, you were talking about using a DS1305, which is
an SPI RTC.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 5 11:24:57 2009
Unfortunatly my DS1305 did not yet arrive and so I was trying to solve
my problem with a DS1302...
What is opinion?
1- Is it much hard work than with a SPI interface?
2 - DS1302 is LSB first whereas Shiftout command is MSB first... I would
need to do some bitwise operations, right?
3 - I would need to set the CE pin manually, right?
Thanks again for all your help
David M.
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 5 12:36:35 2009
Yes, you'll need to control CE via PutPin(). On a quick read of the
DS1302 single-byte read/write specs, it looks like you need to raise CE,
then write a command byte then write a data byte for output to the
'1302, or write a command byte then read a data byte for input from the
'1302, then drop CE.
Reversing the bit order can be done in a simple loop, shifting one byte
value right while the other shifts left, or vice-versa. You might find
that, since you apparently need to loop through the byte anyway, it
might be easier to just output (or input) the bit using PutPin() then,
rather than wait for a complete reversed byte to use ShiftOut() or
ShiftIn(); if you do that you'll also need to generate the clock pulse
with a pair of PutPin(). The data rate would be slower that way but, if
you want to, you can speed it up later once you have something working.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 5 17:52:58 2009
I'll give it a try...
Meanwhile I came across the function FlipBits that, apparently reverses
the bit order automatically...
Have you heard about it?
David
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 5 18:10:56 2009
> ... FlipBits...
Perfect. I've never used it, but that's what you need if you use
ShiftIn/Out.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 10 12:29:00 2009
Hello Tom,
I tried the code that you suggested but with no results...
At the moment I'm just trying to read a register where the first 7 bits
are forced to zero, but my code delivers the decimal value of 255...
Below, I'm sending you the code... May be you have an idea what might I
be doing wrong...
Again, thanks for your help...
Option Explicit
public const SCLK as byte=13
public const MISO as byte=14
public const MOSI as byte=15
public const CE as byte=16
Public Const SecReg As Byte = bx0000_0000 'Seconds Register (#0)
Public Const MinReg As Byte = bx0000_0010 'Minutes Register (#1)
Public Const HrsReg As Byte = bx0000_0100 'Hours Register (#2)
Public Const DayReg As Byte = bx0000_0110 'Day-Of-Month Register (#3)
Public Const DateReg As Byte = bx0000_1000 'Month Register (#4)
Public Const MonReg As Byte = bx0000_1010 'Day of Week Register (#5)
Public Const YrReg As Byte = bx0000_1100 'Year Register (#6)
Public Const CtrlReg As Byte = bx0000_1110 'Control Register (#7)
Public Const TchgReg As Byte = bx0001_0000 'Trickle Charge Register (#8)
Public Const ClockReg as Byte = bx1000_0000
Public Const RAMReg as Byte = bx1100_0000
Public Const ReadReg as Byte = bx1000_0001
Public Const WriteReg as Byte = bx1000_0000
Public Const nb_of_bits as byte=8
Public command as byte
Public received_byte as byte
Public Sub Main()
call delay (1.0) ' para set the Xtal stable
'Reads the control
register___________________________________________________________________________________
do
command=ClockReg OR CtrlReg OR ReadReg
command = FlipBits (command) ' because DS1302 is LSB first
call putpin(CE,bxOutputHigh) ' CE must be asserted high during
communication
Call ShiftOut(MOSI, SCLK, nb_of_bits, command)
received_byte =Shiftin(MISO, SCLK, nb_of_bits)
Call PutPin(SCLK, bxOutputLow) ' sets the SCLK pin to low after
communication
call putpin(CE,bxOutputLow) ' CE must be asserted low after
communication
received_byte=FlipBits(received_byte)
debug.print "ctrl_reg: " ; CStr(received_byte)
call delay (1.0)
loop
End Sub
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 10 12:55:21 2009
> public const MISO as byte=14
> public const MOSI as byte=15
Are these two pins both connected to the DS1302 I/O pin?
Tom
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 10 12:58:49 2009
yes, both pins are connected to IO pin of DS1302
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 10 12:59:06 2009
You can't be far from success. Here is a Cubloc implementation that is
close to Basic-X code:
http://www.cubloc.com/download/etc/app_ds1302.pdf
Tom
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - Tom Becker - Nov 10 13:05:26 2009
> ... both pins are connected to IO pin of DS1302...
Then the output pin will hold the input pin low, won't it? Try
disconnecting one of the pins and use the same pin for input and output.
Tom
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 10 16:38:41 2009
I tried want you suggested: instead of MISO and MOSI pins, I'm only
using one pin connected to IO pin of DS1302...
But the result is the same: "ctrl_reg: 255"
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Keeping track of date and time - David Sousa Mendes - Nov 10 16:47:40 2009
Do you think I should configure the IO pin as bxInputTristate using Putpin?
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Keeping track of date and time - rosa...@aol.com - Nov 10 18:11:57 2009
Hi,
Suggestion
Do a print of the command data to see if your are sending command a good command.
Set the clock low before execute the CE high per DS1302 define instruction.
I know that you are setting it after the shiftin instruction but when you start the
program the setting maybe unknown.
Add a small delay after the shiftout instruction.
See if it help with your problem.
rosarite
-----Original Message-----
From: David Sousa Mendes
To: b...@yahoogroups.com
Sent: Tue, Nov 10, 2009 3:38 pm
Subject: [BasicX] Keeping track of date and time
I tried want you suggested: instead of MISO and MOSI pins, I'm only
using one pin connected to IO pin of DS1302...
But the result is the same: "ctrl_reg: 255"
[Non-text portions of this message have been removed]
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Keeping track of date and time - David Sousa Mendes - Nov 13 9:13:06 2009
Hello fellows
The problem was finnally solved as soon as I called Maxim's support line.
According to their Typical Operation Circuit, I had my supply connected
to Vcc2 pin...
Apparently, when you have a single supply, this should be connected to
Vcc1 and not to Vcc2 as they suggest on their scheme...
When I changed the wires, all started to work properly!
Thanks again for all your help!!
Best regards
David M.
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )