µTasker Forum
µTasker Forum => NXPTM LPC2XXX and LPC17XX => Topic started by: olimex_man on April 22, 2008, 12:30:31 PM
-
Hallo.
As I see the RTC in the Olimex_LPC2378_demo is not enabled. Is that right? Or can´t I find it in the code?
I want to enable the RTC and clock it with the extern oscillator on the board. Tested this in an other program and the RTC was very accurate.
The purpose for running the RTC is that I want to have the exact time every time a value comes to one of the UART´s.
Regards
Martin
-
Hi Martin
It is (unfortunately) correct that the RTC is not yet supported in the uTasker project. You may like to have a go add adding the module.
Otherwise it is also possible to make quite accurate time stamps using the USE_TIME_SERVER support. As long as there is an internet connection the time will be requested from a time server and the seconds incremented every 1. [ulPresentTime in application.c - counts seconds of a day].
In addition there is also the global variable uTaskerSystemTick which counts the number of TICKs (generally 50ms intervals) since the board started. Using these it is possible to time stamp events with quite good accuracy.
However the RTC is a nice feature of the LPC23XX (and smaller devices like the LPC210X) so it would be nice to have a driver interface for it.
Regards
Mark
-
Hi Martin
I have read through the RTC section of the LPC23XX users' manual and compared it also to the module in the smaller devices (LPC210x). The smaller devices don't have sub-second interrupt support and also lack the 2k of battery backed memory but are otherwise compatible.
As a start I have added the register defines below. It doesn't look that difficult to use but some experimenting with battery backup and optimum power saving modes may be needed:
#define RTC_BLOCK 0xe0024000
#define RTC_RAM_BLOCK 0xe0084000 // 2k battery backed up SRAM - only long word accesses supported
// RTC registers
//
#define RTC_ILR *(volatile unsigned long*)(RTC_BLOCK + 0x000) // Interrupt Location Register
#define RTCCIF 0x1 // Counter Increment Interrupt Block generated an interript
#define RTCALF 0x2 // Alarm Registers generated an interript
#define RTSSF 0x4 // Counter Increment Sub-Seconds interrupt block generated an interript
#define RTC_CTC *(volatile unsigned long*)(RTC_BLOCK + 0x004) // Clock Tick Counter Register (read-only)
#define RTC_CCR *(unsigned long*)(RTC_BLOCK + 0x008) // Clock Control Register
#define CCR_CLKEN 0x01 // Enable counters
#define CCR_CTCRST 0x02 // Clock Tick Counter Reset
#define CCR_CLKSRC_32K 0x10 // Clock derived from external 32k source
#define RTC_CIIR *(unsigned long*)(RTC_BLOCK + 0x00c) // Counter Increment Interrupt Register
#define CIIR_IMSEC 0x01 // Interrupt on second increment
#define CIIR_IMMIN 0x02 // Interrupt on minute increment
#define CIIR_IMHOUR 0x04 // Interrupt on hour increment
#define CIIR_IMDOM 0x08 // Interrupt on day of month increment
#define CIIR_IMDOW 0x10 // Interrupt on day of week increment
#define CIIR_IMDOY 0x20 // Interrupt on day of year increment
#define CIIR_IMMON 0x40 // Interrupt on month increment
#define CIIR_IMYEAR 0x80 // Interrupt on year increment
#define RTC_AMR *(unsigned long*)(RTC_BLOCK + 0x010) // Alarm Mask Register
#define AMRSEC 0x01 // No alarm compare on second value
#define AMRMIN 0x02 // No alarm compare on minute value
#define AMRHOUR 0x04 // No alarm compare on hour value
#define AMRDOM 0x08 // No alarm compare on day of month value
#define AMRDOW 0x10 // No alarm compare on day of week value
#define AMRDOY 0x20 // No alarm compare on day of year value
#define AMRMON 0x40 // No alarm compare month value
#define AMRYEAR 0x80 // No alarm compare year value
#define RTC_CTIME0 *(volatile unsigned long*)(RTC_BLOCK + 0x014) // Consolidated Time Register 0 (seconds, minutes, hours, day of week)
#define RTC_CTIME1 *(volatile unsigned long*)(RTC_BLOCK + 0x018) // Consolidated Time Register 1 (day of month, month, year)
#define RTC_CTIME2 *(volatile unsigned long*)(RTC_BLOCK + 0x01c) // Consolidated Time Register 2 (day of year)
#define RTC_SEC *(volatile unsigned long*)(RTC_BLOCK + 0x020) // Seconds 0..59
#define RTC_MIN *(volatile unsigned long*)(RTC_BLOCK + 0x024) // Minutes 0..59
#define RTC_HOUR *(volatile unsigned long*)(RTC_BLOCK + 0x028) // Hours 0..23
#define RTC_DOM *(volatile unsigned long*)(RTC_BLOCK + 0x02c) // Day of Month 1..28/29/30/31
#define RTC_DOW *(volatile unsigned long*)(RTC_BLOCK + 0x030) // Day of Week 0..6
#define RTC_DOY *(volatile unsigned long*)(RTC_BLOCK + 0x034) // Day of Year 1..365/366
#define RTC_MONTH *(volatile unsigned long*)(RTC_BLOCK + 0x038) // Month 1..12
#define RTC_YEAR *(volatile unsigned long*)(RTC_BLOCK + 0x03c) // Year 0..4095
#define RTC_CISS *(volatile unsigned long*)(RTC_BLOCK + 0x040) // Counter Increment Select Ma
#define CISS_16_COUNTS 0x00 // Interrupt each 16 counts of the Clock Tick Timer
#define CISS_32_COUNTS 0x01 // Interrupt each 32 counts of the Clock Tick Timer
#define CISS_64_COUNTS 0x02 // Interrupt each 64 counts of the Clock Tick Timer
#define CISS_128_COUNTS 0x03 // Interrupt each 128 counts of the Clock Tick Timer
#define CISS_256_COUNTS 0x04 // Interrupt each 256 counts of the Clock Tick Timer
#define CISS_512_COUNTS 0x05 // Interrupt each 512 counts of the Clock Tick Timer
#define CISS_1024_COUNTS 0x06 // Interrupt each 1024 counts of the Clock Tick Timer
#define CISS_2048_COUNTS 0x07 // Interrupt each 2048 counts of the Clock Tick Timer
#define CISS_SUBSECENA 0x80 // SubSec Interrupt enabled
#define RTC_ALSEC *(unsigned long*)(RTC_BLOCK + 0x060) // Alarm value for seconds
#define RTC_ALMIN *(unsigned long*)(RTC_BLOCK + 0x064) // Alarm value for minutes
#define RTC_ALHOUR *(unsigned long*)(RTC_BLOCK + 0x068) // Alarm value for hours
#define RTC_ALDOM *(unsigned long*)(RTC_BLOCK + 0x06c) // Alarm value for day of week
#define RTC_ALDOW *(unsigned long*)(RTC_BLOCK + 0x070) // Alarm value for day of month
#define RTC_ALDOY *(unsigned long*)(RTC_BLOCK + 0x074) // Alarm value for day of year
#define RTC_ALMON *(unsigned long*)(RTC_BLOCK + 0x078) // Alarm value for months
#define RTC_ALYEAR *(unsigned long*)(RTC_BLOCK + 0x07c) // Alarm value for years
#define RTC_PREINT *(unsigned long*)(RTC_BLOCK + 0x080) // Prescale Value, Integer Portion
#define RTC_PREFRAC *(unsigned long*)(RTC_BLOCK + 0x084) // Prescale Value, Fractional Portion
Regards
Mark
-
Hi Mark.
Thanks for the work with the register defines. I think next week (no time at the moment) I will try to implement the RTC and then post the results.
Regards
Martin
-
Hi.
I implemented the RTC, but in an very simple mode, since I don't need any power saving modes. And I use the RTC ALARM for getting an update of the RTC values every night , over TCP (from a server). This works fine.
And I implemented a support for the Nokia LCD on the Olimex board. This works fine too. :)
If someone is interested in the code for the RTC or the Nokia LCD I can post it here. (but the code is in an very "early phase", this means not perfect and maybe are errors in it, but it works so it helps getting started)
Regards
Martin
-
Hi Martin
If you would like to post your code there is no problem to do it.
I think that it would be interesting if you could give a short report on the Nokia LCD. I haven't looked at it, but I know that the Olimex boards have it (I know of an article by James Lynch on using it with the ATMEL board - these are seemingly also made by Olimex...):
http://www.sparkfun.com/tutorial/Nokia%206100%20LCD%20Display%20Driver.pdf
(and some more notes here: http://www.nabble.com/FW:-RE:-Nokia-LCD-Display-on-Olimex-SAM7-EX256-running-td15741425.html )
What are your experiences compared to his? What are the strengths and weakness of the the Noka module? Any other tips about controlling it from uTasker?
How advanced is your implementation compared to James'?
By the way - do you use the uTasker simulator for any of your work? I have been using a new graphical LCD simulator (monochrome) in the development project and may introduce it soon to the main project. I wonder whether it could be adapted to also support this display type?
Regards
Mark