RISC5 Real-time Clock support

General discussions about using the Astrobe IDE to program the FPGA RISC5 cpu used in Project Oberon 2013
Post Reply
Site Admin
Posts: 479
Joined: Fri Dec 31, 2010 12:30 pm

RISC5 Real-time Clock support

Post by cfbsoftware » Fri Nov 17, 2017 11:50 pm

The attached file contains the source code of two modules RTC.Mod and SPI1.Mod which provide support in RISC5 Project Oberon for the Maxim DS3234 Real-Time Clock device. The DS3234 is a battery-backed chip that provides continuous time (hours, minutes and seconds) and date (year, month and day) information accurate to +/- 2 minutes per year via an SPI interface.

As well as providing the ability to automatically timestamp Project Oberon files it can be used with the Astrobe HCFiler filesystem functions to implement accurate datalogging applications.

The RTC device is available as a convenient Deadon RTC breakout board from SparkFun:
DS3234 Breakout
rtc.jpg (16.6 KiB) Viewed 21497 times
Links to the schematics, DS3234 datasheet etc. are all available from that webpage.

(There are cheaper knockoffs of the breakout board available on the Internet. However, we tried a couple and wasted a whole lot of time before realising that the battery backup didn't work on both so be warned ...)

What you need to do to make it all happen:

1. Unzip the attached source code files into the folder containing System.Mod and Oberon.Mod.

2. Connect the breakout board to the corresponding pins of the SPI1 port of a Project Oberon system. e.g. the Pmod-D port of the Digilent Arty-7 and Arty-S7 FPGA Development boards. Note: for these systems the GND and VCC connections are reversed.

3. The RTC device uses SPI Mode 3. This requires a change to the RISC5 Verilog file SPI.v :

Change the 0 in the following line to a 1:
assign SCLK = (~rst | rdy) ? 0 : fast ...

assign SCLK = (~rst | rdy) ? 1 : fast ...

(a big thanks to Paul Reed for suggesting this change!)

4. Regenerate the FPGA Bitstream file using the Xilinx tools and reconfigure your target FPGA board.

5. Add RTC to the IMPORT list of Files.Mod, Oberon.Mod and System.Mod and replace calls to Kernel.Clock and Kernel.SetClock in those modules with the corresponding calls RTC.Clock and RTC.SetClock.

6. Rebuild your Project Oberon system.

7. Restart Project Oberon and enter the command System.Date with the current date and time in dd/mm/yy hh:mm:ss format to set the date. Enter the command System.Date without any parameters to display the current date and time:
System.Date Screenshot
SystmDate.JPG (51.49 KiB) Viewed 21497 times
However, if you prefer to wait, the next release of Embedded Project Oberon will include these modifications 'out of the box'.
RTC.Mod, SPI1.Mod
(2.43 KiB) Downloaded 1430 times

Posts: 5
Joined: Sun Oct 20, 2019 6:22 pm

Re: RISC5 Real-time Clock support

Post by mrlx » Sun Oct 20, 2019 6:25 pm

Is it possible to connect the DS3234 to the Pepino LX9?

Site Admin
Posts: 479
Joined: Fri Dec 31, 2010 12:30 pm

Re: RISC5 Real-time Clock support

Post by cfbsoftware » Mon Oct 21, 2019 9:48 am

Yes - if you are not using the nRF24L01+ RF module you can connect the DS3234 to the Pepino LX9 using the J7 connector. The connector pinouts are detailed here:


The Astrobe Pepino disk image includes all of the necessary RTC software and will automatically detect the DS3234 on SPI1 at boot time.

Post Reply