Hi,
thank you for your reply.
I got 3 questions.
1. Isn't 7.37MHz / 8 = 921250Hz, not 921600Hz. Which one is correct??
2. I did "call Timer.startPeriodic(1024);" because according to TEP102, it says
that 1024 milli sec equals to 1 sec. Am I doing right if I want clock to fire
every 1 sec using Atmega1281?
3. If my calculation is correct, microsec overflows pretty quickly (about
40min?). Is there any way that I can make it work longer?
Best,
John
John:
On the iris platform, as it is configured by default, LocalTimeMicroC
provides a 921600Hz clock. What you're seeing is correct.
This is because the MCU clock source is a baud friendly 7.37MHz
crystal, and the prescaler of Timer1 is set to 8. It is possible to
have a 1MHz clock, however, you will need to use the internal
oscillator as the MCU clock source instead. See TEP 102 Appendix C
(mica family) and the ATMega1281 datasheet for details.
Janos
2009/11/7 :
> Hi,
>
> I am using Iris mote and TinyOS-2.x, and trying to get local time in micro
> seconds.
> I put my code at the end of this mail, and my out put looks something like
> this:
> 1024 986787
> 2048 1908532
> 3072 2830276
> 4096 3752021
> ...
> I looked through TEP102, and it says "one second contains 1024 binary
> milliseconds, 32768 32kHz ticks, or 1048576 microseconds", but it seems that
> in my case, microseconds only increases about 921745 for each 1024ms.
> Is this what I'm supposed to get? or I'm doing something wrong?
>
> Also, Is there any way to get microsec in uint64_t??
>
> Best regards,
> John
>
>
>
> __PrintTimeAppC.nc__
> configuration PrintTimeAppC{
> }
> implementation {
> components MainC, PrintTimeC;
> components LocalTimeMicroC;
> components LocalTimeMilliC;
> components new TimerMilliC() as Timer;
> PrintTimeC.Boot -> MainC;
> PrintTimeC.LocalMicro -> LocalTimeMicroC;
> PrintTimeC.LocalTime -> LocalTimeMilliC;
> PrintTimeC.Timer -> Timer;
> }
>
> __PrintTimeC.nc__
> #include "printf.h"
> #include "Timer.h"
> #include "MicaTimer.h"
>
> module PrintTimeC {
> uses {
> interface Boot;
> interface LocalTime as LocalMicro;
> interface LocalTime as LocalTime;
> interface Timer as Timer;
> }
> }
> implementation {
> event void Boot.booted() {
> call Timer.startPeriodic(1024);
> }
> event void Timer.fired() {
> printf("%ld %ld\n", call LocalTime.get(), call LocalMicro.get());
> printfflush();
> }
> }
>
> __Makefile__
> COMPONENT=PrintTimeAppC
> CFLAGS += -I$(TOSDIR)/lib/printf
> CFLAGS += -I$(TOSDIR)/lib/timer
> CFLAGS += -I$(TOSDIR)/platforms/iris
> include $(MAKERULES)
>
>
> ________________________________
> GyaO! - Anime, Dramas, Movies, and Music videos [FREE]
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
---------------------------------
GyaO! - Anime, Dramas, Movies, and Music videos [FREE]
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help