Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1307 TextLCD mbed
main.cpp
00001 // show how the DS1307 class works 00002 #include "ds1307.h" 00003 #include "mbed.h" 00004 #include "TextLCD.h" 00005 00006 DS1307 my1307(p9,p10); // start DS1307 class and give it pins for connections of the DS1307 device 00007 TextLCD lcd(p21,p22,p23,p24,p25,p26); 00008 00009 int sec; 00010 int min; 00011 int hours; 00012 int day; 00013 int date; 00014 int month; 00015 int year; 00016 00017 void test_rw(int test) { 00018 } 00019 00020 int main() { 00021 int junk = 0; 00022 00023 while(1){ 00024 wait(0.5); 00025 00026 test_rw(my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year)); 00027 00028 lcd.cls(); 00029 lcd.locate(0,0); 00030 lcd.printf("%d:%d:%d",hours,min,sec); 00031 lcd.locate(0,1); 00032 lcd.printf("%d/%d/%d",date,month,year); 00033 00034 junk = 0x39; // just a junk value do read and write test to DS1307 ram 00035 test_rw(my1307.write( 0x20, junk)); // this should write the value of junk to register 0x20 (a ram location) in the ds1307. 00036 junk = 0; // clear junk to show that when the register is read from the correct value is obtained 00037 test_rw(my1307.read( 0x20, &junk)); // this should read register 0x20 00038 } 00039 }
Generated on Thu Jul 21 2022 03:20:59 by
