Datalogger RTC

Questions about the BASICtools and MakeItC
Post Reply
olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Datalogger RTC

Post by olzeke51 »

I put a battery , crystal, and caps on my Datalogger .
battery+ on J8 pin, and battery- on Arduino GND
ARMbasic 934f and 8.35b kernel are throwing RTC_(variable) errors.
Did the "#define USE_timing" and other RTC software get into the kernel??
[I added the LPC4330 define in the CPU checks of the RTC.bas file]

Olzeke51



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Datalogger RTC

Post by basicchip »

The USE_timing is part of RTC.bas, which we have not gotten to changing for 4330, and I looked inside the LPC43xx.bas file and the defines for RTC have not been translated from the C version.

Not sure what the best way to say this is, but when we need something in BASIC we fix it. But that means you can either wait for us to do it, or you can give us a hand and post the updates here. The community of users is what really makes things like the Arduino successful, no small group of people can accomplish that, and as 2 people writing software we qualify as a small group.

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: Datalogger RTC

Post by olzeke51 »

Thanks Bruce, I'll tackle that one. I just briefly looked at the RTC_alarm function and they are
tied together in some aspects.
Glad to help out, one small footstep .... oh, wrong venue !!
Okay community....
Gary

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: Datalogger RTC

Post by olzeke51 »

here are some of the #defines for the timing circuits (all prettied up - from the conglomerated LPC43xx.bas file)
**********
updated -- see next post

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: Datalogger RTC

Post by olzeke51 »

I owe you an apology, Basicchip...
Based on the 'USE_timing' define in the RTC.bas file; I assumed the RTC_(variables) were kernel variables
I looked in the lpc17xx.bas file and saw them #defined !!!
'
okay community ... here is an updated version of LPC43xx.bas [snippet] #defines to match the
variable names used in RTC.bas (I will later make/post my own RTC43.bas file)
'NOTICE there is now a bigger REGFILE section that is VBAT powered
'
'// ---------------------------------------------------------------------
'// ----- ATIMER
'// ---------------------------------------------------------------------
' * @brief Product name title=UM10430 Chapter title=LPC43xx Alarm timer Modification date=1/7/2011 Major revision=0 Minor revision=6 (ATIMER)
' */

#define DOWNCOUNTER *&H40040000 ' Downcounter register
#define PRESET *&H40040004 ' Preset value register
#define CLR_EN *&H40040FD8 ' Interrupt clear enable register
#define SET_EN *&H40040FDC ' Interrupt set enable register
#define STATUS *&H40040FE0 ' Status register
'??? ALSO on RTC_ALARM chip pin 120
#define ENABLE *&H40040FE4 ' Enable register
#define CLR_STAT *&H40040FE8 ' Clear register
#define SET_STAT *&H40040FEC ' Set register

'// --------------------------------------------------------------------
'// ----- REGFILE
'// --------------------------------------------------------------------
' * @brief Product name title=UM10430 Chapter title=LPC43xx rtc/REGFILE date=1/20/2011 Major revision=0 Minor revision=7 (REGFILE)
' */

'typedef struct '{ < (* &H40041000) REGFILE Structure ' */
'__IO uint32_t REGFILE[64] '/* General purpose storage register */
'} LPC_REGFILE_Type
' THESE are available in the RTC power domain (VBAT) '//olzeke51
#define REGFILE_BASE_ADDR &H40041000
#define REGFILE0 *(REGFILE_BASE_ADDR + &H00)
#define REGFILE1 *(REGFILE_BASE_ADDR + &H04)
#define REGFILE2 *(REGFILE_BASE_ADDR + &H08)
#define REGFILE3 *(REGFILE_BASE_ADDR + &H0C)
' AND SO ON
#define REGFILE62 *(REGFILE_BASE_ADDR + &HF8)
#define REGFILE63 *(REGFILE_BASE_ADDR + &HFC)

// ----------------------------------------------------------------------
'// ----- CREG
'// ---------------------------------------------------------------------
' * @brief Product name title=UM10430 Chapter title=LPC43xx Configuration Registers (CREG) Modification date=1/20/2011 Major revision=0 Minor revision=7 (CREG)
' modified Jan 23,2015 by Olzeke51 for use the RTC43.bas file
' */


#define IRCTRM *&H40043000 ' IRC trim register
#define CREG0 *&H40043004 'Chip configuration register 32 kHz
'oscillator output and BOD control register.
#define PMUCON *&H40043008 'Power mode control register.
#define M4MEMMAP *&H40043100 'ARM Cortex-M4 memory mapping
#define CREG5 *&H40043118 'Chip configuration register 5.
'Controls JTAG access.
#define DMAMUX *&H4004311C 'DMA muxing control
#define ETBCFG *&H40043128 'ETB RAM configuration
#define CREG6 *&H4004312C 'tbd.
#define CHIPID *&H40043200 'Part ID #

'// ---------------------------------------------------------------------
'// ----- RTC
'// ---------------------------------------------------------------------
' * @brief Product name title=UM10430 Chapter title=LPC43xx Real-Time Clock (RTC) Modification date=1/20/2011 Major revision=0 Minor revision=7 (RTC)

' #defines USED by Coridium ARMBasic
#define RTC_BASE_ADDR &H40046000
#define RTC_ILR *(RTC_BASE_ADDR + &H00)
'reserved *(RTC_BASE_ADDR + &H04)
#define RTC_CCR *(RTC_BASE_ADDR + &H08)
#define RTC_CIIR *(RTC_BASE_ADDR + &H0C)
#define RTC_AMR *(RTC_BASE_ADDR + &H10)
#define RTC_CTIME0 *(RTC_BASE_ADDR + &H14)
#define RTC_CTIME1 *(RTC_BASE_ADDR + &H18)
#define RTC_CTIME2 *(RTC_BASE_ADDR + &H1C)
#define RTC_SEC *(RTC_BASE_ADDR + &H20)
#define RTC_MIN *(RTC_BASE_ADDR + &H24)
#define RTC_HOUR *(RTC_BASE_ADDR + &H28)
#define RTC_DOM *(RTC_BASE_ADDR + &H2C)
#define RTC_DAY *(RTC_BASE_ADDR + &H2C) ' //aka
#define RTC_DOW *(RTC_BASE_ADDR + &H30)
#define RTC_DOY *(RTC_BASE_ADDR + &H34)
#define RTC_MONTH *(RTC_BASE_ADDR + &H38)
#define RTC_YEAR *(RTC_BASE_ADDR + &H3C)
#define RTC_CAL *(RTC_BASE_ADDR + &H40) '//changed

#define RTC_ALSEC *(RTC_BASE_ADDR + &H60)
#define RTC_ALMIN *(RTC_BASE_ADDR + &H64)
#define RTC_ALHOUR *(RTC_BASE_ADDR + &H68)
#define RTC_ALDOM *(RTC_BASE_ADDR + &H6C)
#define RTC_ALDOW *(RTC_BASE_ADDR + &H70)
#define RTC_ALDOY *(RTC_BASE_ADDR + &H74)
#define RTC_ALMON *(RTC_BASE_ADDR + &H78)
#define RTC_ALYEAR *(RTC_BASE_ADDR + &H7C)

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: Datalogger RTC

Post by olzeke51 »

this is a double post --its in the 'Datalogger Resources" also
this should end this particular thread
*****
initializing code for the RTC - add/incorporate into your RTC.bas as appropriate
'========================================================================================
'
' Hardware Interface -- real time clock functions
''
' INITIALIZATION CODE added to turn on & enable the RTC domain & clock -25 Jan 2015 olzeke51
'
' copyright Coridium Corp, 2008, may be used with Coridium Hardware or licensees
'/* modified by Olzeke51 for Coridium Datalogger [LPC4330] Jan 21,2015
'========================================================================================

#ifndef USE_timing 'Coridium original
#define USE_timing 'Coridium original


#ifdef LPC4330
#include <LPC43xx.bas>
#else
#error program is made for the LPC4330 series
#endif
'*****************************
SUB rtc_init

CREG0 = &H3FC3 'turns on power and oscillators - 1khz & 32Khz
'bits 7&6 ; bits 13&12 set to 0x03 to save battery current - errata sheet 25Jan2013
' event router not being used - as no low power modes used

RTC_CCR = &H0001 'enables the RTC registers
RTC_AMR = &HFF 'turns off alarm because all 1's
'the ATIMER (alarm timer) section indicated this was needed
'IF I didn't implement or set up the interrupt/event router routines
WAIT(2000) 'lets the registers start counting
'
' check to see if alarm_timer /1HZ clock is runnning
'used primarily for debugging - watch the STOP command !!!
'
'PRESET = 4000 ' so the DOWNCOUNTER has something to work with
'dim start, finish
'start = DOWNCOUNTER
'WAIT(150)
'finish = DOWNCOUNTER
'IF start = finish
' print "downcounter not working in Alarm/RTCTimer"
' STOP
'ENDIF
'

ENDSUB

Post Reply