{"id":374,"date":"2022-06-08T11:44:00","date_gmt":"2022-06-08T11:44:00","guid":{"rendered":"https:\/\/vegaprocessors.in\/blog\/?p=374"},"modified":"2022-06-13T08:22:18","modified_gmt":"2022-06-13T08:22:18","slug":"rtc-with-aries-v2-board","status":"publish","type":"post","link":"https:\/\/vegaprocessors.in\/blog\/rtc-with-aries-v2-board\/","title":{"rendered":"RTC with ARIES V2 Board"},"content":{"rendered":"\n<p>In this tutorial, we will see how we can interface DS3231 RTC module to ARIES V2 board. <strong>Real Time Clock<\/strong> (RTC) is an electronic device which is used to provide precise time and date in various applications like GPS, Servers, Data loggers etc. It is powered by an on board lithium battery, which makes RTC work even when the power is off.<\/p>\n\n\n\n<p> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">DS3231 RTC<\/h2>\n\n\n\n<p>The <strong>DS3231<\/strong> RTC module is  low cost and communicates over <strong>I2C interface<\/strong> having a supply voltage range from 2.3V to 5.5V . It has an in built crystal oscillator and temperature sensor which makes the IC more compact. A secondary EEPROM IC of 32 KB size is also provided with this module. To provide uninterrupted power supply, there is a provision to provide battery also.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Real-Time-Clock-Module-for-Arduino-DS3231-AT24C32-both-side.jpg\" alt=\"\" class=\"wp-image-396\" width=\"432\" height=\"432\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Real-Time-Clock-Module-for-Arduino-DS3231-AT24C32-both-side.jpg 800w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Real-Time-Clock-Module-for-Arduino-DS3231-AT24C32-both-side-300x300.jpg 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Real-Time-Clock-Module-for-Arduino-DS3231-AT24C32-both-side-150x150.jpg 150w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/Real-Time-Clock-Module-for-Arduino-DS3231-AT24C32-both-side-768x768.jpg 768w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Circuit Diagram<\/h2>\n\n\n\n<p>Connect SDA and SCL pins of DS3231 RTC module to SDA1 and SCL1 pins of ARIES V2 board. Then connect VCC and GND of the RTC module to +3.3V and GND respectively of the ARIES board. (Refer <a href=\"https:\/\/datasheets.maximintegrated.com\/en\/ds\/DS3231.pdf\">DS3231 datasheet<\/a>).<\/p>\n\n\n\n<p>Now, for powering up the ARIES v2 board via USB port of a Laptop\/Desktop\/PC and burning the code into the ARIES v2 board, we have to use a micro USB type B to USB type A cable. The cable should be connected to <strong>UART0<\/strong> port of the ARIES v2 board, and the Laptop\/Desktop\/PC should be preinstalled with VEGA SDK and Toolchain.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>DS3231<\/strong><\/td><td><strong>ARIES v2 Board<\/strong><\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>SCL<\/td><td>SCL1<\/td><\/tr><tr><td>SDA<\/td><td>SDA1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/rtc_ckt.png\" alt=\"\" class=\"wp-image-1355\" width=\"553\" height=\"400\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/rtc_ckt.png 498w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/rtc_ckt-300x217.png 300w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<p>After setting up the tool chain and SDK path environments, set the date and time by editing the file in set_RTC_DS3231. You can make set date, month, year and time as shown in the following sample code.<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color\"><code>\/**\n @fn main\n \n @param&#91;in] No input parameters.\n @param&#91;Out] No ouput parameter.\n @return Void function.\n\n *\/\nvoid main() {\n\t\/\/UC rxd_data&#91;7];\n\tprintf(\" I2C ds3231 RTC\\n\\r\");\n\ti2c_configure(I2C_1, SYS_FREQ, I2C_FREQ); \/\/System clock =40MHz and I2C clock =100 kHz\n\t\/\/i2c_initialize(0);\n\n\tgRTCtime.sec = 00; \/\/ <strong>Edit here to set seconds<\/strong>\n\tgRTCtime.min = 20; \/\/ <strong>Edit here to set the minutes<\/strong>\n\tgRTCtime.hour = 4; \/\/ <strong>Edit here to set the hour<\/strong>\n\tgRTCtime.mday = 7; \/\/<strong>Edit here to set the day<\/strong>\n\tgRTCtime.mon = 6; \/\/<strong>Edit here to set the month<\/strong>\n\tgRTCtime.year = 2022; \/\/ <strong>Edit here to set the year<\/strong>\n\tgRTCtime.wday = 3; \/\/<strong>Edit here to set the day of the week<\/strong>\n\tgRTCtime.year_s = 20;\n\n\tprintf(\" set value : %02d-%02d-%02d, %02d:%02d:%02d \\n\\r\", gRTCtime.mday, gRTCtime.mon,\n\t\t\t\tgRTCtime.year_s, gRTCtime.hour, gRTCtime.min, gRTCtime.sec);\n\ti2c_set_rtc_DS3231(I2C_1, DS3231_TIME_CAL_ADDR, DS3231_I2C_ADDR_WR);\n\tprintf(\" write completed\\n\\r\");\n\twhile (1) {\n\t\ti2c_get_rtc_DS3231(I2C_1, DS3231_I2C_ADDR_WR,\n\t\tDS3231_I2C_ADDR_RD, DS3231_TIME_CAL_ADDR);\n\n\t\tprintf(\"\\r %02x-%02x-%02x, %02x:%02x:%02x, \", gRTCtime.mday, gRTCtime.mon,\n\t\t\t\tgRTCtime.year_s, gRTCtime.hour, gRTCtime.min, gRTCtime.sec);\n\t\tswitch (gRTCtime.wday) {\n\t\tcase 1:\n\t\t\tprintf(\"Sunday   \");\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tprintf(\"Monday   \");\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tprintf(\"Tuesday  \");\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tprintf(\"Wednesday\");\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tprintf(\"Thursday \");\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tprintf(\"Friday   \");\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tprintf(\"Saturday \");\n\t\t\tbreak;\n\n\t\t}\n\t\tudelay(2000);\n\t}\n\n\t\/\/printf(\"success \\n\\r\");\n\t\/\/while (1)\n\t\/\/;\n}\n<\/code><\/pre>\n\n\n\n<p>Clean the executable by using the <strong>make clean<\/strong> command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd examples\/i2c\/rtc_ds3231\/set_RTC_DS3231<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>make clean<\/code><\/pre>\n\n\n\n<p>Build the edited example program for setting DS3231 RTC by using <strong>make<\/strong> command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make <\/code><\/pre>\n\n\n\n<p>Before transfering the built program to board, ensure that you have connected the UART0 connector of the board to the PC.<\/p>\n\n\n\n<p>Open a new terminal, execute the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo minicom aries<\/code><\/pre>\n\n\n\n<p>Now you can see the minicom terminal opened and the board UART terminal is ready<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"689\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-7.png\" alt=\"\" class=\"wp-image-605\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-7.png 820w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-7-300x252.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/05\/minicom-7-768x645.png 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/figure>\n\n\n\n<p>Use <strong>CTRL+A S<\/strong> to enter file sending menu and select <strong>xmodem<\/strong> by pressing <strong>Enter<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"615\" height=\"143\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/04\/Screenshot-from-2021-04-30-16-14-03.png\" alt=\"\" class=\"wp-image-230\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/04\/Screenshot-from-2021-04-30-16-14-03.png 615w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2021\/04\/Screenshot-from-2021-04-30-16-14-03-300x70.png 300w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/figure>\n\n\n\n<p>In the next window, with <strong>space bar<\/strong> select the <strong>i2c_rtc.bin<\/strong> file to be transferred, by pressing <strong>Enter<\/strong>, transfer process starts.<\/p>\n\n\n\n<p>Wait until the process is completed. The screen should display how much data has been transferred.<\/p>\n\n\n\n<p>After completing transfer, the Program will start to execute.<\/p>\n\n\n\n<p>The set RTC date and time will be displayed on minicom UART terminal. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"759\" height=\"556\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-07-16-40-31.png\" alt=\"\" class=\"wp-image-1327\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-07-16-40-31.png 759w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-07-16-40-31-300x220.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><\/figure>\n\n\n\n<p>Note: After setting the date and time in RTC, you can compile and run examples\/i2c\/rtc_ds3231\/read_RTC_DS3231 to read back and display the date, time and day of the week on minicom(if using the same RTC).<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will see how we can interface DS3231 RTC module to ARIES V2 board. Real Time Clock (RTC) is an electronic device which is used to provide precise time and date in various applications like GPS, Servers, Data loggers etc. It is powered by an on board lithium battery, which makes RTC [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,14,1],"tags":[75,76,7,87,66,86,26,31,24],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-getting-started","category-tutorials","category-uncategorized","tag-aries-v2-board","tag-c-dac","tag-cdac","tag-ds3231","tag-iic","tag-rtc","tag-thejas-64","tag-thejas32","tag-vegaprocessor"],"_links":{"self":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":17,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":1447,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions\/1447"}],"wp:attachment":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}