Pradeep Kotipalli
/
rtc_justtest
bgf
Revision 0:a07e5a4c94bb, committed 2014-12-20
- Comitter:
- pradeepvk2208
- Date:
- Sat Dec 20 12:17:15 2014 +0000
- Commit message:
- dfghj
Changed in this revision
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 a07e5a4c94bb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 20 12:17:15 2014 +0000 @@ -0,0 +1,101 @@ +#include "mbed.h" + +SPI spi(PTD6, PTD7, PTD5); // mosi, miso, sclk +DigitalOut cs(D9); + + +int main() +{ + + + + // Setup the spi for 8 bit data, high steady state clock, + // second edge capture, with a 1MHz clock rate + spi.format(8,3); + spi.frequency(1000000); + + cs = 0; + spi.write(0x80); // set write register to seconds + spi.write(0x01); // send value of zero + + //cs=1; + //cs=0; + spi.write(0x81); + spi.write(0x58); //write reg to minutes + + //cs=1; + //cs=0; + + spi.write(0x82); + spi.write(0x01); //write reg to hours (00-23) + + spi.write(0x83); + spi.write(0x01); //write reg to day (1-7) + + spi.write(0x84); + spi.write(0x01); //write reg to date(01-31) + + spi.write(0x85); + spi.write(0x01); //write reg to mnth(01-12) + + spi.write(0x86); + spi.write(0x01); //write reg to year(00-99) + + cs=1; + // Receive the contents of the seconds register + + for(int i=0;i<1000000;i++){ + + + cs=0; + spi.write(0x00); // set read register to seconds + int seconds = spi.write(0x00); // read the value by sending dummy byte + + cs=1; + cs=0; + + spi.write(0x01); + int minutes =spi.write(0x01); + + cs=1; + cs=0; + + spi.write(0x02); + int hours =spi.write(0x01); + + cs=1; + cs=0; + + spi.write(0x03); + int day =spi.write(0x01); + + cs=1; + cs=0; + + spi.write(0x04); + int date =spi.write(0x01); + + cs=1; + cs=0; + + spi.write(0x05); + int mnth =spi.write(0x01); + + cs=1; + cs=0; + + spi.write(0x06); + int year =spi.write(0x01); + + //This cs=1 is to make the chipselect line high to "deselect" the slave in our case RTC + cs = 1; + + //This printf function is to check the timestamp function in the terminal output + printf("timestamp as = %X : %X : %X : %X : %X : %X : %X\n\r", year,mnth,date,day,hours,minutes,seconds); + } + + + + return 0; + + } \ No newline at end of file
diff -r 000000000000 -r a07e5a4c94bb mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 20 12:17:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file