Simple test of DS1302 Real Time Clock module and an STM32 NUCLEO F441RE board.

Dependencies:   mbed DS1302

https://os.mbed.com/media/uploads/loarri/20210609_225026_girata.jpg

Files at this revision

API Documentation at this revision

Comitter:
loarri
Date:
Wed Jun 09 20:06:08 2021 +0000
Commit message:
Simple test for DS1302 Real Time clock module and a STM NUCLEO F411RE board.

Changed in this revision

DS1302.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2a445788550e DS1302.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1302.lib	Wed Jun 09 20:06:08 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/DS1302/#9a746f303e59
diff -r 000000000000 -r 2a445788550e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 09 20:06:08 2021 +0000
@@ -0,0 +1,42 @@
+/*
+--------------------
+Author: L. Arrigoni
+May 2021
+--------------------
+
+Simple test with RTC module and STM32F411RE Nucleo board.
+DS1302 powered by 3.3 V without pull up resistor on I2C lines
+
+*/
+
+
+#define SCLK    D15
+#define IO      D14
+#define CE      D8
+
+//Comment this line if the DS1302 is already running
+//#define INITIAL_RUN
+
+#include "mbed.h"
+#include "DS1302.h"
+
+DS1302 clk(SCLK, IO, CE);
+
+int main() {
+    #ifdef INITIAL_RUN
+    //clk.set_time(1256729737);
+    clk.set_time(1623257900);  //from https://www.unixtimestamp.com/
+    #endif
+    
+    char storedByte = clk.recallByte(0);
+    printf("\r\nStored byte was %d, now increasing by one\r\n", storedByte);
+    clk.storeByte(0, storedByte + 1);
+    
+    while(1) {
+        time_t seconds = clk.time(NULL);
+        printf("Date and time: %s\r", ctime(&seconds));
+        wait(1);
+    }
+}
+
+
diff -r 000000000000 -r 2a445788550e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 09 20:06:08 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file