RTC project
Dependencies: DS1307 TextLCD mbed
Diff: main.cpp
- Revision:
- 0:a1b3b73a7312
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 27 10:29:01 2014 +0000 @@ -0,0 +1,39 @@ +// show how the DS1307 class works + #include "ds1307.h" + #include "mbed.h" + #include "TextLCD.h" + + DS1307 my1307(p9,p10); // start DS1307 class and give it pins for connections of the DS1307 device + TextLCD lcd(p21,p22,p23,p24,p25,p26); + + int sec; + int min; + int hours; + int day; + int date; + int month; + int year; + + void test_rw(int test) { +} + + int main() { + int junk = 0; + +while(1){ + wait(0.5); + + test_rw(my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year)); + + lcd.cls(); + lcd.locate(0,0); + lcd.printf("%d:%d:%d",hours,min,sec); + lcd.locate(0,1); + lcd.printf("%d/%d/%d",date,month,year); + + junk = 0x39; // just a junk value do read and write test to DS1307 ram + test_rw(my1307.write( 0x20, junk)); // this should write the value of junk to register 0x20 (a ram location) in the ds1307. + junk = 0; // clear junk to show that when the register is read from the correct value is obtained + test_rw(my1307.read( 0x20, &junk)); // this should read register 0x20 + } + } \ No newline at end of file