News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Real Time Clock Board

Started by dxs, 19:14, 10 February 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Would you be interested in buying a RTC board?

Yes. Definitely, as a complete standalone.
16 (30.2%)
Only if usable in parallel with the X-MEM.
23 (43.4%)
Only as a module to plug on my physical ROMBOARD I already have.
3 (5.7%)
No thanks.
11 (20.8%)

Total Members Voted: 53

ikonsgr

Ok, to establish the hardware design, i need to know how exactly the communication through software is done. So, if i get it right so far, the procedure is:
- Mount time rom in ULIfAC's rom board in slot X, Select the time rom slot (with OUT &DF00,X),enable upper rom (with OUT &7F00,Y), and then read any byte from time rom even from Basic using PEEK from &C000-&FFFF range.To enable access to time chip registers:
- Give 64 rom reads from &C000 or &C001 (e.g. PEEK(&C000) or PEEK(&C001) in Basic) in specific sequence, according to activation pattern. If any of the 64 reads is not "Correct" (according to activation pattern) then the hole procedure is reset.
- After successful activation you give another 64 "rom" reads to access time chip registers as follow:
      PEEK(&C000) write bit '0'
      PEEK(&C001) write bit '1'
      PEEK(&C004) read bit from Data Bit 0
After that, the time chip is disabled, and you need to give again the 64 read pattern to re-enable access to time chip registers.
Can you confirm that this is right way to communicate with time rom and time chip?


ikonsgr

#327
Quote from: d_kef on 09:38, 06 April 25Yep! That's it.
d_kef
Ok, in that case you don't need any of the CS, OE, WR signals, and since DS1216 has both build-in crystal and lithium battery, practically you just need to connect DS1216's A0,A2,D0 and power supply, right?
Now, instead of needing to mount Time Rom from a rom file each time you boot Amstrad CPC, i'm thinking of including Time Rom chip in MCU program memory, and access it exactly like with Amsdos emulation on CPC 464. Of course all the needed activation/deactivation functions will be done through PIC mcu code too, so apart from DS1216, nothing extra will be needed ;)
 The only... "disadvantage" of this approach will be the somewhat slower access to time rom, affecting all reads from time rom (read/write access to time chip after activation, can be done in ~1uS time frame for every bit, thus avoid any speed penalty), but from what i understand, all software supporting RTC (symbos, CP/M, future OS etc), communicate with time rom/chip every second, so i don't think that a few dozens uSec delay per  second, will affect that actual running speed of the OS, right?

Pollo

It is true that that you can access the Dobbertin RTC in Basic without using the RSX, and using the PEEK method instead.

It is just that it will be very cumbersome.

I suggest you try to do so in WinAPE, so that you are sure you have understood how it works. WinAPE can emulate the Dobbertin RTC.

d_kef

#329
Quote from: ikonsgr on 10:38, 06 April 25in that case you don't need any of the CS, OE, WR signals,
I don't think you can get away with this so easily.

from the datasheet
QuoteThe SmartWatch uses the VCC, data I/O 0, CE, OE, and WE for RAM and watch control. All other pins are passed straight through to the socket receptacle.
and
Quotecommunication  with  the  clock  is  established  using  A2  and  A0,  and either OE or CE.

It is highly improbable to accidentally send the activating sequence, but not impossible. So I'd stay on the safe side and enable the RTC only when reading from or writing to it.

edit: maybe it is safe to tie /CS to the CPC /ROMEN.

d_kef

ikonsgr

Quote from: d_kef on 11:21, 06 April 25
Quote from: ikonsgr on 10:38, 06 April 25in that case you don't need any of the CS, OE, WR signals,
I don't think you can get away with this so easily.

from the datasheet
QuoteThe SmartWatch uses the VCC, data I/O 0, CE, OE, and WE for RAM and watch control. All other pins are passed straight through to the socket receptacle.
and
Quotecommunication  with  the  clock  is  established  using  A2  and  A0,  and either OE or CE.

It is highly improbable to accidentally send the activating sequence, but not impossible. So I'd stay on the safe side and enable the RTC only when reading from or writing to it.

d_kef
I've read this too, but practically all the communication process (activation and access registers of time chip) doesn't seem to involve any of CS,OE, WR signals! Since read/write mode is specifically determined from A2 state ('1' or '0') and A0/D0 are used for getting the write/read bit, any other signals seemed to be irrelevant, at least for the special serial communication with time chip .
 Anyway, it seems that WR is not required at all, so if i connect CS to "romen" and OE to NOT A2 i think it will ensure that both of these signals are properly active upon serial communication, don't you think?

ikonsgr

#331
btw, @d_kef did you look at "PATTERN MATCH—ROM" section of DS1216 datasheet? None of the OE,CS,WR are mentioned there...  ::)
Also i noticed that prior to 64 activation rom reads (which are actually writes for the time chip...), you need to give a PEEK(&C004): " Prior to executing the first of 64 write cycles, a read cycle should be executed by holding A2 high."

d_kef

Quote from: ikonsgr on 12:31, 06 April 25btw, @d_kef did you look at "PATTERN MATCH—ROM" section of DS1216 datasheet? None of the OE,CS,WR are mentioned there...  ::)
Also i noticed that prior to 64 activation rom reads (which are actually writes for the time chip...), you need to give a PEEK(&C004): " Prior to executing the first of 64 write cycles, a read cycle should be executed by holding A2 high."
True. So you just have to try it...

d_kef

ikonsgr

Indeed, i took a look at the READ/WRITE timing diagrams too ,and the sure thing is that CS must be always active upon READ/WRITE, so i will connect it to Romen as you suggested. Also, it seems that when you are in "Rom-smart watch" mode, the WR can be always inactive-high, and OE must be active on READ and also can be active on WRITE...  ::)

d_kef

#334
Taking as granded that the DS1216 was placed in a standard ROM board slot back in the day it is safe to asume that /WE is not needed.
Furthermore the timing diagram refers to /WE(RAM) so it could be write to the piggibacked nonvolatile RAM. It is confusing though.
Having tested this code I'd say that /CS=/ROMEN and /OE=/RD is enough for it to work.

In order to be 100% sure that you don't need to drive /CS only when the specific ROM is enabled you need to know how existing software like SymbOS and FutureOS is detecting the presence of the RTC. If they just detect the TIMEROM+ ROM (the most obvious method) then you can do /CS=/ROMEN.

d_kef

ikonsgr

Quote from: d_kef on 13:41, 06 April 25Taking as granded that the DS1216 was placed in a standard ROM board slot back in the day it is safe to asume that /WE is not needed.
Furthermore the timing diagram refers to /WE(RAM) so it could be write to the piggibacked nonvolatile RAM. It is confusing though.
Having tested this code I'd say that /CS=/ROMEN and /OE=/RD is enough for it to work.

d_kef
I agree,for start, i will go for this pinout and we'll see how it goes :)
Btw, for testing RTC, i suppose i could use the rsx commands of time rom or maybe symbos to see if it is recognized correctly as dobbertin RTC ,right?
Thanks again for all your help  ;)

d_kef

A little more open eyes and everything becomes clear!!!
DS1216B/C/D/H are intrrnally configured for piggyback RAM.
DS1216E/F are internally configured for piggyback ROM. So the Dobbertin Smart Watch is a DS1216E in which case /WE is not connected internally to anything.

See the application note for a good explanation and make sure you order a DS1216E for your tests.

d_kef

d_kef

@ikonsgr  looking at this thread I just realized that we hijacked it.
Maybe it is better to move the recent posts to another thread.

d_kef

GUNHED

Quote from: d_kef on 12:14, 03 April 25
Quote from: ikonsgr on 11:49, 03 April 25I thought that this is done using RSX commands from the Time rom,  so no extra logic would be needed. Also if extra logic is needed, how the original Dobbertin's RTC worked as it was consisted only from the DS1216 adapter+ time rom above?
My understanding is that you MUST have also the TIMER ROM+ installed on top of the DS1216. The TIMER ROM and the DS1216 are both using the same ROM number.
When you want to access the RTC then you select the TIMER ROM, activate the CPC upper ROM and then you send an "activating sequence". As soon as the DS1216 gets the activating sequence it disables access to the ROM and you can read or write the 8 bytes of clock data. Otherwise you access the TIMER ROM data.

So back in the day the DS1216 and the ROM was just placed in an empty slot of your ROM board and you could use it imediately. If you don't have a physical ROM board (the case of ULIFAC) then you have to be creative....

d_kef

No, the ROM is not necessary. It contains software for for the clock support. But you can also have your own driver of 30 to 50 bytes of code only.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

Quote from: Pollo on 13:27, 03 April 25Looking at the SF2 chip more closely, it is not that rosy. The RTC chip is quite bloated: it has a square wave generator, an interrupt generator and many status registers.

And the Nova chip looks so nice, I have to admit. 32KB NVRAM for the CPC devs and a simple RTC with clean hardware access, even from Basic. No rom needed.

The TimerROM+ is mandatory for the Dobbertin to be used from Basic.
Dobbertin RTC: No, you can use your own RSX if you like
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

Quote from: Pollo on 11:58, 05 April 25
Quote from: ikonsgr on 09:38, 05 April 25If i get it right, if you have time rom installed in different place (and not upon DS1216 adapter)
The time ROM needs to be on the same ROM slot as the time chip otherwise it won't work.
No, the Time-ROM can be on another ROM-select. I have them on different places.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Pollo

Quote from: GUNHED on 20:48, 06 April 25
Quote from: Pollo on 11:58, 05 April 25
Quote from: ikonsgr on 09:38, 05 April 25If i get it right, if you have time rom installed in different place (and not upon DS1216 adapter)
The time ROM needs to be on the same ROM slot as the time chip otherwise it won't work.
No, the Time-ROM can be on another ROM-select. I have them on different places.
Oh, I didn't know that. So the Time-ROM is smarter than I thought. Good to know.


Prodatron

Quote from: d_kef on 13:41, 06 April 25In order to be 100% sure that you don't need to drive /CS only when the specific ROM is enabled you need to know how existing software like SymbOS is detecting the presence of the RTC. If they just detect the TIMEROM+ ROM (the most obvious method) then you can do /CS=/ROMEN.
SymbOS is searching for the TIME.SET RSX command. It will then use this ROM.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

ikonsgr

Ok, to sum up, from what i understand, the Dobbetin Smart Watch must be the oldest RTC for CPC, and thus, it is supported by all available OS for CPC (Symbos, FutureOS, CP/M) and also provide RSX commands for direct use in Basic.
Fortunately, although the RTC DS1216E module used is obsolete, you can still find it today, in apparently large quantities and quite cheap too: https://vi.aliexpress.com/w/wholesale-DS1216E.html?spm=a2g0o.productlist.search.0
My only concern is that, as most of these DS1216 modules can be many years old, if this can affect the internal lithium battery and cant' retain time/date when Amstrad is off. ::)
Anyway, i've decided to add RTC support for ULIfAC by adding the DS1216E module, as from hardware point of view it's the easiest, and maybe the cheaper way to do it, as it doesn't need extra Logic, external Crystal or external backup battery like other solutions. Of course, support for the required Time Rom and activation function, will be done by software through ULIfAC's PIC MCU.
So, you think that this is a good choice? :)
 

Pollo

I would go for the Nova personally, as just thinking about the Dobbertin gives me some headache  :)



ikonsgr

#346
Quote from: Pollo on 12:31, 07 April 25I would go for the Nova personally, as just thinking about the Dobbertin gives me some headache  :)

Well, if you just take a look here: https://www.cpcwiki.eu/imgs/d/dd/Nova_cpc_nvram.pdf
Then, it will be ME having a.... NOVA RTC headache!  :laugh:
Seriously, this might be a very nice RTC implementation, but unfortunately all these modern RTC that use IORQ and require full 16bit address decoding and 8bit data bus, need quite much  extra logic to implement it (if you check the thread a few pages before, you will see that initially, i wanted to go for an emulation of  SYMBiFACE_II  RTC using about the same RTC design as NOVA board, but it ended up needing quite a few extra ic's too).
 If we are talking for a dedicative RTC board then this might not be an issue, but here, we are talking for adding RTC support to a multi function card that already is quite complex (as ULIfAC offers mass storage, wifi, rom board, ram expansion, C3 RAM configuration support for CPC 464...), so we need a solution with the least extra hardware needed ;)
Btw, for your headache, check this:
https://www.cpcwiki.eu/index.php/Dobbertin_Smart_Watch:RTC_routines
Ready made routines to ease your... pain  :D

Prodatron

Quote from: ikonsgr on 13:41, 07 April 25Btw, for your headache, check this:
https://www.cpcwiki.eu/index.php/Dobbertin_Smart_Watch:RTC_routines
Ready made routines to ease your... pain  :D
TBH this code looks like a headache indeed, you can see very good how strange you have to access this ;D

Anyway Pollo is right about, that Nova and SF2 is easier to implement on software side (you save about half of the code compared to Dobbertin).

I don't agree about the better software support for the Dobbertin. There maybe no CP/M driver for the others, but that is 1.) trivial to do and 2.) noone will care about this anyway.

But I fully understand, if it's easier for Ikonsgr to implement the Dobbertin, than it's just cool that he adds an RTC to the Ulifac at all.

For me it doesn't matter, in SymbOS all these RTCs are supported anyway, and the crazy CPU usage just for requesting the time is at not a dealbreaker at the end, as it only happens every 50 frames.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

d_kef


If I had to rank them from the easier to the most complex to program:
1) SF2  ++ detection, ++reading/writing
2) SF3  ++ detection, +reading/writing
3) NOVA -detection (paging in/out RAM), -reading/writing (paging in/out RAM)
4) M4 --detection (ROM walk), -reading (paging in/out ROM), no writing
5) Dobbertin --detection (ROM walk), --reading/writing (paging in/out ROM, send enable sequence, bitstream using A0, A2, D0)

Of course there is no real problem with any of them and from the hardware point of view you should do whatever is more convenient and cost efficient.

Quote from: Prodatron on 14:02, 07 April 25There maybe no CP/M driver for the others
Not a driver per se, but you can always use RTC.COM to update CP/M from RTC or RTC from CP/M. It supports all 5 RTCs above.

d_kef

Prodatron

#349
Quote from: d_kef on 14:16, 07 April 25If I had to rank them from the easier to the most complex to program:
1) SF2  ++ detection, ++reading/writing
2) SF3  ++ detection, +reading/writing
3) NOVA -detection (paging in/out RAM), -reading/writing (paging in/out RAM)
4) M4 --detection (ROM walk), -reading (paging in/out ROM), no writing
5) Dobbertin --detection (ROM walk), --reading/writing (paging in/out ROM, send enable sequence, bitstream using A0, A2, D0)
I fully agree to this.

Quote from: d_kef on 14:16, 07 April 25you can always use RTC.COM to update CP/M from RTC or RTC from CP/M. It supports all 5 RTCs above.
Thanks a lot for this tool! So there is indeed software support for CP/M as well :)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Powered by SMFPacks Menu Editor Mod