Page 1 of 1
TIMER
Posted: Sun Oct 28, 2012 7:40 pm
by YahooArchive
>from support line
>In Basic, the timer counts microseconds. What is the largest value (
in days ? ,hours,minutes)that the timer can hold before it hits its
sizing limit?
You can do the following check-
start = TIMER
while (TIMER - start < some_value)
where some_value is less than 71 minutes
got that from $100000000 / 1000000 uS/S / 60 sec/min
Use WAIT for longer times, which is good to 49 days -- called with
milliseconds
I guess this is not Windows so you can reassonably expect to run longer
than that

In that case use SLEEP which is set in seconds and good
for 136 years
Re: TIMER
Posted: Tue Oct 30, 2012 12:04 am
by YahooArchive
> I'm programming an ARMite board using the C compiler. I would like
to
> know how many bits are used for the free-running timer. I'm
wondering
> how long it will run before it resets.
Same answer for bot C and BASIC
The TIMER uses the hardware TIMER0 which is a 32 counter that ticks
every microsecond.
So the timer rolls over 4.294 billion ticks, which is about 1.2 hours
So if you are generating a wait using
if (start - TIMER < sometime)
sometime has to be less than 1.2 hours. the WAIT routine will
generate longer times up to 49 days
Re: TIMER
Posted: Wed Oct 31, 2012 4:22 pm
by YahooArchive
You can just write to them. The #defines already take care of it for
you:
//generate interrupt on match on PPM_E_TIMER_CHANNEL
TIMER_MCR(PPM_TIMER) |= TIMER_MRxI(PPM_E_TIMER_CHANNEL);
this is a snippet from my timer init code I wrote for Timer1. It uses
some parameterized #defines I wrote to parameterize the access to the
timers. Check armmite.zip/ppm.c and armmite.zip/hw.h respectively.
I've tried to comment the initialization to help out.
Here's the code, as promised in earlier threads:
http://sites.google.com/site/robocopter ... /Home/code
Be forewarned, Timer0 is used by the Coridium library (e.g. TIMER). I
believe the interrupt is unused though.
John
--- In
ARMexpress@yahoogroups.com, "Dan Lee" <danlee_58@...> wrote:
>
> I'm trying to setup Timer0 to generate and interrupt on Match
Control
> Register 0. LPC210x.h defines the Timer Control Register as T0_TCR,
and
> the Match Control Register as T0_MCR. I need to load those registers
> with a '1" and '3' respectively. How do I load these registers in C?
>
Re: TIMER
Posted: Wed Oct 31, 2012 4:24 pm
by YahooArchive
> I included LPC210x.h. I though that would define the Timer
registers, but I had to define them in the module.
>
In C the peripheral register set is defined in LPC210x.h
Inside that file there are sections devoted to the TIMERs, and you
would use the defined pointers like
T0_MR0 = 0x1234;
time = T0_TC;
These names for the most part match register definitions in the NXP
User Manual, and this header file is modified from the release of GCC
tools.
There is another #define in coridium.h that defines TIMER as T0_TC,
that is equivalent to the ARMbasic definition, for people that are
transitioning from BASIC to C.
In BASIC an equivalent file to LPC210x.h has not been generated, but
as registers are used in BASIC they have been defined in the
individual libraries. Their use is similar to C (from HWPWM.bas)
T0_MR0 = $1234
time = T0_TC
For simplicity TIMER is a keyword in the BASIC compiler that is
compiled as * $E0004008