[En-Nut-Discussion] Timing on AVR32

Daniel Fiedler (Ethernut) ethernut at fitus.de
Tue May 15 16:36:58 CEST 2012


Hi Thiago and everyone else,

 

I have written an Time-Clock for AVR32. I used an NutTimer with 1000ms
timing. But clock counting is twice to slow.  I also created a BlinkingLed
Thread. With a NutWait command with 150ms wait time but LED blinks slowly.
I resume the clock frequency of cpu is set not correctly. Or the system
timer of nut/os is to slow. 

 

Does anyone have an idea. 

 

Some snippets of my clock code:

 

Init:

NutThreadCreate( (char *)"TimeThread", TimeThread, &clockEvent, 512 );

       

clockTimer = NutTimerStart(1000, TimerCallback, &clockEvent, 0);

 

 

THREAD( TimeThread, arg)

{

       

       tm *ntp_datetime;

       

       NutThreadSetPriority(16);

    for (;;) {

        if (NutEventWait(arg, 0)) {

            // Timeout

                    puts ( "TimeThread Event timeout\n" );

             }            

        else {

                    // Event triggered 

                    ntp_time++;

                    

                    ntp_datetime = localtime(&ntp_time);

                    printf("time is: %02d:%02d:%02d\n",
ntp_datetime->tm_hour, ntp_datetime->tm_min, ntp_datetime->tm_sec);

                    printf("date is: %02d.%02d.%04d\n",
ntp_datetime->tm_mday, ntp_datetime->tm_mon+1, ntp_datetime->tm_year+1900);

             }                   

            

    }

}

 

void TimerCallback(HANDLE timer, void *arg)

{

    NutEventPostAsync(arg);

}

 




More information about the En-Nut-Discussion mailing list