View Full Version : Embedded systems...anyone wanna take a stab?
SilverJester
10-13-2010, 03:05 PM
Well I've been staring at this question (from my embedded systems class) for an hour now and can't figure out how to start it. There's no way I'm getting it done in time for class since I have to leave in 15mins, but now I'm just curious how to answer it. Anyone here have an idea how to answer this thing?
Question (verbatim including grammatical errors):
Given a 200 MHz crystal-controlled oscillator and a 32-bit and any number of 16-bit terminal-count timers, design a real-time clock that outputs the date and time down to the milliseconds. You can ignore leap years. Binary output is fine. Draw a diagram and indicate terminal-count values for all timers.
I really want to use a prescaler but it since it doesn't mention the use of one, I don't think I'm allowed to.
DocWalt
10-13-2010, 03:16 PM
It doesn't say you can't use one... If it wasn't allowed, it would say it ;)
marshallh
10-13-2010, 03:33 PM
At 200mhz, cycle time is 5ns (1/200)
Terminal-count means that the counter asserts after it reaches some arbitrary value. You can either let the counter run its full course, or stop it with a value within in its range.
16bit counter gives 65536 clocks (2^16)
32bit counter gives 4294967296 clocks (2^32)
It's easier to start at the smallest value and daisy chain them.
The finest granularity they need is 1 millisecond.
1ms = 1,000,000ns. Cycle time of 5ns gives 200,000 clocks. So we need the 32bit counter for this.
Each counter feeds into the next one.
First 32-bit counter: terminal count of 200,000. This gives miliseconds
Second 16-bit counter: 1,000. This gives seconds
3rd counter: 60. Minutes
4th counter: 60. Hours
5th counter: 24. Days
6th counter: 365. Years
You get the idea. Each counter feeds the next one after it.
EDIT: I may be off on the exact meaning of a terminal counter. In any case, the principle is the same. I'm not sure why your guy came up with 200mhz. Typical crystal value for a RTC oscillator is 32.768khz. This is very convenient because you can prescale with a power of 2, which lets you cheat when designing the counter and save silicon.
terrets
10-13-2010, 04:08 PM
Id say its allowed :).
R/T93
10-13-2010, 07:52 PM
At 200mhz, cycle time is 5ns (1/200)
Terminal-count means that the counter asserts after it reaches some arbitrary value. You can either let the counter run its full course, or stop it with a value within in its range.
16bit counter gives 65536 clocks (2^16)
32bit counter gives 4294967296 clocks (2^32)
It's easier to start at the smallest value and daisy chain them.
The finest granularity they need is 1 millisecond.
1ms = 1,000,000ns. Cycle time of 5ns gives 200,000 clocks. So we need the 32bit counter for this.
Each counter feeds into the next one.
First 32-bit counter: terminal count of 200,000. This gives miliseconds
Second 16-bit counter: 1,000. This gives seconds
3rd counter: 60. Minutes
4th counter: 60. Hours
5th counter: 24. Days
6th counter: 365. Years
You get the idea. Each counter feeds the next one after it.
EDIT: I may be off on the exact meaning of a terminal counter. In any case, the principle is the same. I'm not sure why your guy came up with 200mhz. Typical crystal value for a RTC oscillator is 32.768khz. This is very convenient because you can prescale with a power of 2, which lets you cheat when designing the counter and save silicon.
This post makes me feel slow in the head :/
Me Mongo, Mongo like candy!!!
Austin@STM
10-13-2010, 09:11 PM
This post makes me feel slow in the head :/
Me Mongo, Mongo like candy!!!
I agree, im gonna color by number to feel better :p
terrets
10-14-2010, 01:09 AM
This post makes me feel slow in the head :/
Me Mongo, Mongo like candy!!!
:lol:
SilverJester
10-14-2010, 10:20 AM
At 200mhz, cycle time is 5ns (1/200)
Terminal-count means that the counter asserts after it reaches some arbitrary value. You can either let the counter run its full course, or stop it with a value within in its range.
16bit counter gives 65536 clocks (2^16)
32bit counter gives 4294967296 clocks (2^32)
It's easier to start at the smallest value and daisy chain them.
The finest granularity they need is 1 millisecond.
1ms = 1,000,000ns. Cycle time of 5ns gives 200,000 clocks. So we need the 32bit counter for this.
Each counter feeds into the next one.
First 32-bit counter: terminal count of 200,000. This gives miliseconds
Second 16-bit counter: 1,000. This gives seconds
3rd counter: 60. Minutes
4th counter: 60. Hours
5th counter: 24. Days
6th counter: 365. Years
You get the idea. Each counter feeds the next one after it.
EDIT: I may be off on the exact meaning of a terminal counter. In any case, the principle is the same. I'm not sure why your guy came up with 200mhz. Typical crystal value for a RTC oscillator is 32.768khz. This is very convenient because you can prescale with a power of 2, which lets you cheat when designing the counter and save silicon.
Winner! This is basically how it's done.
In case you're wondering, your basic idea of a terminal counter is right except that it will always run to it's max value (16-bit 65536 as you said). But you can adjust the starting aka terminal value so that it doesn't always start from 0.
Thanks for the response!
B-Man
10-14-2010, 10:25 AM
Winner! This is basically how it's done.
In case you're wondering, your basic idea of a terminal counter is right except that it will always run to it's max value (16-bit 65536 as you said). But you can adjust the starting aka terminal value so that it doesn't always start from 0.
Thanks for the response!
You may be trying to say the same thing, but you'd set a compare register and throw an interrupt when the counter and compare register is equal. Most systems allow a reset of the counter when this interrupt happens.
Powered by vBulletin® Version 4.2.3 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.