![]() |
Forum Index : Microcontroller and PC projects : E-100 RTC module fun...
Author | Message | ||||
Zonker![]() Guru ![]() Joined: 18/08/2012 Location: United StatesPosts: 767 |
Evening Gents... Having the awesome E-100 module and a 4.3" LCD attached along with the DS3231 RTC module allows you to use pin 50 as an interrupt generator. I setup the "SQW" pin on the RTC module to pulse low every second. Doing this turns out to be a simple task now the firmware supports the RTC SETREG and RTC GETREG commands. In your program setup section add: Dim rtc_temp As integer SetPin 50,intl,sec_int,pullup ' input pin from RTC SQW pin rtc setreg 14,0 ' set RTC SQW pin to output 1hz pulse Then, have the interrupt routine display the time.. Sub sec_int RTC getreg 17,rtc_temp Text 0,260,Time$+" "+Date$+" "+Str$(rtc_temp)+Chr$(96)+"C" End Sub As a bonus, you can also read the RTC internal temp register and get that data too..! I think you can also set RTC register 14 just once at the command line prompt and the RTC will keep the setting even if the E-100 is powered down. Just to be sure it gets set, including the command in your program and forcing reg 14 to 0 every time it is run doesn't seem to hurt anything either... The sec_int subroutine example I have here puts the RTC data on the LCD display on a "lower status line" but you can also just make it a print statement and output the data to the console if wanted... There are more things you can do with the RTC, like store data that is retrievable on powerup... I will keep playing... I like this..! ![]() |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Nice feedback Zonker! ![]() |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9590 |
Nice one, my son. ![]() I knew someone would use that PIN-51 header if we routed that pin out! ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Zonker![]() Guru ![]() Joined: 18/08/2012 Location: United StatesPosts: 767 |
Bummer... I found out by finishing reading the manual, there is not any general RAM bytes in the DS3231.... ![]() I did update the action code... Dim rtc_temp As integer Dim rtc_quarters As integer Dim temp_c As float Dim temp_f As float SetPin 50,intl,sec_int,pullup ' input pin from RTC SQW pin rtc setreg 14,0 ' set RTC SQW pin to output 1hz pulse do: loop Sub sec_int RTC getreg 17,rtc_temp RTC getreg 18,rtc_quarters rtc_quarters=rtc_quarters>>6 rtc_quarters=rtc_quarters*25 temp_c=rtc_temp+rtc_quarters/10 temp_f=temp_c*9/5+32 Text 0,260,Time$+" "+Date$+" "+Str$(temp_c,3,2)+Chr$(96)+"C"+" "+Str$(temp_f,3,2)+Chr$(96)+"F" End Sub A little "clunky" but seems to work... ![]() |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Bummer that it doesn't have the DS3232, always a use for NV-RAM in process control, such as part counting, etc. https://www.maximintegrated.com/en/app-notes/index.mvp/id/5143 |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Complete noob, here. I have the E-100 (received yesterday) but have yet to power it up and write my first line of code so please excuse any dumb questions. Reading the manual, I find SETTICK. Is there any benefit to doing the above instead? I can see how the RTC can go beyond 1KHz but any other benefit to using a hardware interrupt instead? Cheers. Tinine |
||||
BobD![]() Guru ![]() Joined: 07/12/2011 Location: AustraliaPosts: 935 |
That same module that Zonker refers to also has the AT24C32 eeprom on board which may prove useful for you. |
||||
Zonker![]() Guru ![]() Joined: 18/08/2012 Location: United StatesPosts: 767 |
@Tinine.. Not much difference, but the RTC int would be "synced" with the seconds in the RCT, so you could setup counters ect. that would stay correct and not drift with the MM system clock... I just wanted to try it out and see if it works ok... ![]() |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2431 |
I can see how the RTC can go beyond 1KHz but any other benefit to using a hardware interrupt instead? if using a micromite that supports CLOCKTRIM (the MX170 does, am not sure about MX470 and MZ devices) you can use the the external hardware interrupt to 'dicipline' the internal oscillator of the micromite. this will mean that the whole micromite will keep in sync with the external source, be it a 1Hz output from a RTC module, or the (absolutely precise when locked on to a satellite) 1Hz output from a GPS module. see this thread: http://www.thebackshed.com/forum/forum_posts.asp?TID=9295 the downside of this approach is that a small 'jitter' will be introduced, as the internal clock is sped up and slowed down by a fraction to keep in sync. if the micromite clock is controlled by an external crystal, it is conceivable that this approach could still be used by switching in an external trim capacitor to tweak the crystal frequency, but it would be tricky to get right. cheers, rob :-) |
||||
Zonker![]() Guru ![]() Joined: 18/08/2012 Location: United StatesPosts: 767 |
Yep.. Probably not much use for anything, I was just playing around with the commands that get into the hardware of the RTC.. At least we can read the DIE temp of the IC for free.. If there were a DS3232, we could have some free RAM to play with... ![]() |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
With the RTC, you can set it to trigger the interrupt at a set time each day. eg 3 minutes past 1 am every day That would have some use and save a lot of BASIC code. Jim VK7JH MMedit |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
![]() Actually, thinking about it, calcs based on those ^2 interrupt frequencies (1024Hz, etc.) could benefit from bit shifting as opposed to multiplying. The concern with the EEPROM, however is the limited erase/write cycles. |
||||
Zonker![]() Guru ![]() Joined: 18/08/2012 Location: United StatesPosts: 767 |
Yea.. And, I haven't played around with the alarm registers yet either... I do like getting the most out of the hardware you have strapped on.. ![]() |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |