Counting Seconds

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Counting Seconds

1,444 Views
carlosmscabral
Contributor I
Hello there,


In my application, I must be able to count seconds (1-10 seconds). This will be the time a LED will be on.
I use the MCF52221. The application doesn't need to run in full clock speed. I thought I could use the general puporse timers, but using the original clock, a second would be to much time for the counter to count. So, I think I need to divide the clock of the system, but there are to much options (internal oscillator, relaxation oscillator) and configurations.

Again, I simply need to be able to count seconds. What is the smartest way to do that?

(sorry for the newbie question, again. I'm just a brazilian undergrad student trying to learn everything by myself)

Thanks!



Labels (1)
0 Kudos
Reply
3 Replies

466 Views
RichTestardi
Senior Contributor II
Hi,
 
If you are looking for a sample project for the MCF52221, I have posted one here:
 
 
The project is named skeleton.zip and includes a timer (and a variable, "uint32 seconds;", that counts seconds, maintained in sources/timer.c).  You'd want to build the "Skeleton 52221" target.  If you run it on the M52221DEMO board, you'll see the LED blink.  You can also connect to USB in host or device mode (see readme.txt).
 
I believe you can never have too much sample code when trying to create something new, so I extracted all the general purpose codes from my three projects into the skeleton.zip archive to share with folks.
 
If you want to start with the archive, feel free to e-mail me any questions or whatever at rich@testardi.com -- it looks like I should have some unexpected free time coming up, being laid off, so I'll be hopefully working with some of this again.
 
-- Rich
0 Kudos
Reply

466 Views
SimonMarsden_de
Contributor II
The simplest thing would be to use a different timer. Instead of the General Purpose Timer (GPT), you could try either the Real Time Clock (RTC) or a Programmable Interrupt Timer (PIT).

The RTC counts in seconds, and you can set an alarm after a specified number of seconds.

The PIT can be configured for a timeout count of up to around a minute.

You might be interested to take a look at an application called ColdFire Init. This is a free tool which runs on Windows machines. It presents a graphical interface allowing you to configure a ColdFire processor, or just individual modules like the RTC and the PITs. It then allows you to auto-generate the appropriate intialisation code in C or assembler.

ColdFire Init is available from:

http://www.microapl.co.uk/CFInit/cfinit_main.html

The MCF52221 is one of the supported processors (The tool does not do any ColdFire V1 parts)


Hope this helps


Simon
0 Kudos
Reply

466 Views
mjbcswitzerland
Specialist V
Hi Carlos

Take a look at the uTasker project.
It contains various methods for counting (using RTC, PIT, DMA Timer or operating system timers):
eg.
http://www.utasker.com/forum/index.php?topic=35.0
http://www.utasker.com/docs/uTasker/uTaskerTimers.PDF

In addition, it supports USB on the M52221 for virtual COM as well as for firmware uploading, so you will have a very complete project to learn with. All can be simulated on the PC and it is completely free for study use - including support on its own forum for the Coldfire:
http://www.utasker.com/forum/index.php?board=2.0

Regards

Mark

www.uTasker.com

0 Kudos
Reply