Discussion group dedicated to the Philips LPC2000 family of ARM MCUs
WinARM LPC2138 example - Mario Ivancic - Aug 24 15:00:37 2006
Hi boys and girls (if any)!
I am looking at sysTime.c in lpc2138_uart0_irq WinARM example and I have a question
regarding uint32_t getSysTICs(void).
Currently code looks like this:
static uint32_t sysTICs;
static uint32_t lastT0TC;
uint32_t getSysTICs(void)
{
uint32_t now = T0TC;
sysTICs += (uint32_t)(now - lastT0TC);
lastT0TC = now;
return sysTICs;
}
So, if we take series of timer snapshots t0, t1, t2, t3 this function will return
values:
for t0: now = t0; sysTICs = 0 + (t0 - 0) = t0; lastT0TC = t0; return t0;
for t1: now = t1; sysTICs = t0 + (t1 - t0) = t1; lastT0TC = t1; return t1;
for t2: now = t2; sysTICs = t1 + (t2 - t1) = t2; lastT0TC = t2; return t2;
for t3: ....
So, why not make getSysTICs( ) like this:
uint32_t getSysTICs(void)
{
return T0TC;
}
or just a macro:
#define getSysTICs( ) (T0TC)
Function uint32_t getElapsedSysTICs(uint32_t startTime)
can be a macro too:
#define getElapsedSysTICs(startTime) (getSysTICs( ) - (startTime))
I am waiting for comments on this.
Best regards,
Mario
[Non-text portions of this message have been removed]

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: WinARM LPC2138 example - rtstofer - Aug 24 15:22:48 2006
--- In l...@yahoogroups.com, "Mario Ivancic"
wrote:
>
> Hi boys and girls (if any)!
>
> I am looking at sysTime.c in lpc2138_uart0_irq WinARM example and I
have a question regarding uint32_t getSysTICs(void).
> Currently code looks like this:
>
> static uint32_t sysTICs;
> static uint32_t lastT0TC;
>
> uint32_t getSysTICs(void)
> {
> uint32_t now = T0TC;
>
> sysTICs += (uint32_t)(now - lastT0TC);
> lastT0TC = now;
> return sysTICs;
> }
>
> So, if we take series of timer snapshots t0, t1, t2, t3 this
function will return values:
> for t0: now = t0; sysTICs = 0 + (t0 - 0) = t0; lastT0TC = t0; return t0;
> for t1: now = t1; sysTICs = t0 + (t1 - t0) = t1; lastT0TC = t1;
return t1;
> for t2: now = t2; sysTICs = t1 + (t2 - t1) = t2; lastT0TC = t2;
return t2;
> for t3: ....
>
> So, why not make getSysTICs( ) like this:
> uint32_t getSysTICs(void)
> {
> return T0TC;
> }
> or just a macro:
> #define getSysTICs( ) (T0TC)
>
> Function uint32_t getElapsedSysTICs(uint32_t startTime)
> can be a macro too:
> #define getElapsedSysTICs(startTime) (getSysTICs( ) - (startTime))
> I am waiting for comments on this.
>
> Best regards,
>
> Mario
>
> [Non-text portions of this message have been removed]
>
Maybe in some architectures T0TC isn't 32 bits?
It's not clear to me that getSysTICs() as a macro results in a uint32_t.
It's also not clear what type is returned by the macro
getElapsedSysTICS(startTime) nor is the type of startTime defined.
I try to avoid macros but I know there are folks here that can create
them properly. I'm not one of them...
Richard
Richard

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )Re: Re: WinARM LPC2138 example - "K B...@lascaux" - Aug 24 16:43:07 2006
Atleast I know that STR71X series :Timer registers are 16bit only.
K B Shah
----- Original Message -----
From: rtstofer
To: l...@yahoogroups.com
Sent: Thursday, August 24, 2006 3:09 PM
Subject: [lpc2000] Re: WinARM LPC2138 example
--- In l...@yahoogroups.com, "Mario Ivancic"
wrote:
>
> Hi boys and girls (if any)!
>
> I am looking at sysTime.c in lpc2138_uart0_irq WinARM example and I
have a question regarding uint32_t getSysTICs(void).
> Currently code looks like this:
>
> static uint32_t sysTICs;
> static uint32_t lastT0TC;
>
> uint32_t getSysTICs(void)
> {
> uint32_t now = T0TC;
>
> sysTICs += (uint32_t)(now - lastT0TC);
> lastT0TC = now;
> return sysTICs;
> }
>
> So, if we take series of timer snapshots t0, t1, t2, t3 this
function will return values:
> for t0: now = t0; sysTICs = 0 + (t0 - 0) = t0; lastT0TC = t0; return t0;
> for t1: now = t1; sysTICs = t0 + (t1 - t0) = t1; lastT0TC = t1;
return t1;
> for t2: now = t2; sysTICs = t1 + (t2 - t1) = t2; lastT0TC = t2;
return t2;
> for t3: ....
>
> So, why not make getSysTICs( ) like this:
> uint32_t getSysTICs(void)
> {
> return T0TC;
> }
> or just a macro:
> #define getSysTICs( ) (T0TC)
>
> Function uint32_t getElapsedSysTICs(uint32_t startTime)
> can be a macro too:
> #define getElapsedSysTICs(startTime) (getSysTICs( ) - (startTime))
>
>
> I am waiting for comments on this.
>
> Best regards,
>
> Mario
>
> [Non-text portions of this message have been removed]
>
Maybe in some architectures T0TC isn't 32 bits?
It's not clear to me that getSysTICs() as a macro results in a uint32_t.
It's also not clear what type is returned by the macro
getElapsedSysTICS(startTime) nor is the type of startTime defined.
I try to avoid macros but I know there are folks here that can create
them properly. I'm not one of them...
Richard
Richard
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.5/426 - Release Date: 8/23/2006
[Non-text portions of this message have been removed]
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )Re: Re: WinARM LPC2138 example - Mario Ivancic - Aug 24 16:52:50 2006
----- Original Message -----
From: rtstofer
To: l...@yahoogroups.com
Sent: Thursday, August 24, 2006 9:09 PM
Subject: [lpc2000] Re: WinARM LPC2138 example
--- In l...@yahoogroups.com, "Mario Ivancic"
wrote:
>
> Hi boys and girls (if any)!
>
> I am looking at sysTime.c in lpc2138_uart0_irq WinARM example and I
have a question regarding uint32_t getSysTICs(void).
> Currently code looks like this:
>
> static uint32_t sysTICs;
> static uint32_t lastT0TC;
>
> uint32_t getSysTICs(void)
> {
> uint32_t now = T0TC;
>
> sysTICs += (uint32_t)(now - lastT0TC);
> lastT0TC = now;
> return sysTICs;
> }
>
> So, if we take series of timer snapshots t0, t1, t2, t3 this
function will return values:
> for t0: now = t0; sysTICs = 0 + (t0 - 0) = t0; lastT0TC = t0; return t0;
> for t1: now = t1; sysTICs = t0 + (t1 - t0) = t1; lastT0TC = t1;
return t1;
> for t2: now = t2; sysTICs = t1 + (t2 - t1) = t2; lastT0TC = t2;
return t2;
> for t3: ....
>
> So, why not make getSysTICs( ) like this:
> uint32_t getSysTICs(void)
> {
> return T0TC;
> }
> or just a macro:
> #define getSysTICs( ) (T0TC)
>
> Function uint32_t getElapsedSysTICs(uint32_t startTime)
> can be a macro too:
> #define getElapsedSysTICs(startTime) (getSysTICs( ) - (startTime))
> I am waiting for comments on this.
>
> Best regards,
>
> Mario
>
> [Non-text portions of this message have been removed]
>
Maybe in some architectures T0TC isn't 32 bits?
It's not clear to me that getSysTICs() as a macro results in a uint32_t.
[Mario]
On LPC2138 T0TC is 32-bit value, but macro or function is secondary
question. Primary question is why to use variables
static uint32_t sysTICs;
static uint32_t lastT0TC;
when you can get the same result by just returning 32-bit value from
timer/counter
Best regards,
Mario
It's also not clear what type is returned by the macro
getElapsedSysTICS(startTime) nor is the type of startTime defined.
I try to avoid macros but I know there are folks here that can create
them properly. I'm not one of them...
Richard
Richard
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )Re: WinARM LPC2138 example - rtstofer - Aug 24 18:21:24 2006
> [Mario]
> On LPC2138 T0TC is 32-bit value, but macro or function is secondary
> question. Primary question is why to use variables
> static uint32_t sysTICs;
> static uint32_t lastT0TC;
> when you can get the same result by just returning 32-bit value from
> timer/counter
>
> Best regards,
> Mario
You can, for your own use, just return the timer value because you
KNOW that on the only platform of interest, the timer is 32 bits.
However, that would be a very poor solution for a general purpose
library such as WinARM where it can be expected that the library will
accomodate timers with other than 32 bits.
And, of course, your own code just became non-portable. But, a lot of
folks write their own support code. It may be non-portable but it
will be a lot smaller.
Maintaining the static variables may be useful for a real time
scheduler. There may very well be other routines in the library that
use those variables. Maybe a global search of the source will find them.
Writing code that is platform independent is very difficult. I agree
that it seems strange and is certainly the long way round but it is
likely to work on a lot of architectures.
Richard

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: WinARM LPC2138 example - rtstofer - Aug 24 19:20:10 2006
I wonder why those static variables aren't declared as volatile? I
guess I would have to see the rest of the code but it seems to me that
if a value is changed in an interrupt routine and also used by some
other function, it should be declared volatile.
Richard

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: WinARM LPC2138 example - Regulus Berdin - Aug 24 21:25:52 2006
Mario Ivancic wrote:
> So, if we take series of timer snapshots t0, t1, t2, t3 this function
> will return values:
> for t0: now = t0; sysTICs = 0 + (t0 - 0) = t0; lastT0TC = t0; return t0;
> for t1: now = t1; sysTICs = t0 + (t1 - t0) = t1; lastT0TC = t1; return t1;
> for t2: now = t2; sysTICs = t1 + (t2 - t1) = t2; lastT0TC = t2; return t2;
> for t3: ....
>
> So, why not make getSysTICs( ) like this:
> uint32_t getSysTICs(void)
> {
> return T0TC;
> }
> or just a macro:
> #define getSysTICs( ) (T0TC)
>
> Function uint32_t getElapsedSysTICs(uint32_t startTime)
> can be a macro too:
> #define getElapsedSysTICs(startTime) (getSysTICs( ) - (startTime))
The problem with the macro or the function returning only the T0TC
register value is when T0TC wraps back to 0 in between calls of
getSysTICs().
This problem was solved by saving the last T0TC and subtracting it with
the current T0TC value. The function is well made and the sysTICs
static variable can even be upgraded to 64 bits or more if needed on
fast T0TC increments.
regards,
Reggie
http://www.microelektronics.com

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Samples for LPC2xxx - John Chung - Aug 25 4:53:37 2006
Hi,
I was wondering whether Philips provide samples for
the LPC2xxx family. I know Microchip does.
Thanks
John
__________________________________________________
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: Samples for LPC2xxx - philips_apps - Aug 25 17:15:08 2006
--- In l...@yahoogroups.com, John Chung
wrote:
>
> Hi,
>
> I was wondering whether Philips provide samples for
> the LPC2xxx family. I know Microchip does.
>
> Thanks
> John
>
> __________________________________________________
John,
Philips provides samples for brand new devices while they can not be
obtained through distribution, which is usually a time periode right
after the product announcement.
Once devices are in volume production and readily available through
e.g. www.digikey.com or your local distributor if he supports single
piece quantities, samples are handled through these channels.
Philips Apps
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )