RISC5 Real-time Clock support

General discussions about using the Astrobe IDE to program the FPGA RISC5 cpu used in Project Oberon 2013

RISC5 Real-time Clock support

Postby 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:

rtc.jpg
DS3234 Breakout
rtc.jpg (16.6 KiB) Viewed 101 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 ...

i.e.
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:

SystmDate.JPG
System.Date Screenshot
SystmDate.JPG (51.49 KiB) Viewed 101 times

However, if you prefer to wait, the next release of Embedded Project Oberon will include these modifications 'out of the box'.
Attachments
RTC.zip
RTC.Mod, SPI1.Mod
(2.43 KiB) Downloaded 34 times
cfbsoftware
Site Admin
 
Posts: 299
Joined: Fri Dec 31, 2010 12:30 pm

Return to Astrobe for FPGA RISC5

cron