how to use timer tiny 6410 /miny 6410

Sudhanshu Mehta
hi All ,

i need some source code example for using timers on tiny 6410 or mini6410.

thanks
Sudhanshu

Juergen Beisert
What is bad with the HRT the kernel provides?

Sudhanshu Mehta
Hi Juergen,

i am new with linux and friendly arm,

please provide some link or source code example for the same.

thanks
Sudhanshu

Sudhanshu Mehta
any one having running timer code ?? i need sys_tick() kind of stuff

Juergen Beisert
Once again: What is wrong with the HRT API the kernel provides to you? Why
you do need access to the hardware instead?

Sudhanshu Mehta
Hi Juergen,

i have no problem in using that as well.

can you please provide some sample code or some web link for that.?

THanks
Sudhanshu

Juergen Beisert
My question was meant to get an idea what you want to do. Just doing some
things in userspace periodically could be done with the help of the generic
POSIX timer API. But maybe you want to control a motor or something else,
then this API is not enough and you also need real-time support in the
kernel.
Otherwise search the web for timer_create(), timer_settime(), setitimer()
and friends. A nice source how to deal with periodic jobs in a real-time
Linux environment is the small tool 'cyclictest'.

Sudhanshu Mehta
Hi all,

thanks juergen for your guidence..

i have done some google
using below code i can use timer with accuracy 1 sec.. but not less than
that.. i have worked on embedded c till date.. lil new to linux.. i am
expecting time which i can use even for 1 millisecond... do you have some
sample code for same


#include <stdio.h>
#include <signal.h>
#include <sys/time.h>

#define INTERVAL 5

int howmany = 0;

void alarm_wakeup (int i)
{
   struct itimerval tout_val;

   signal(SIGALRM,alarm_wakeup);

   howmany += INTERVAL;
   
   printf("\n%d sec up partner, Wakeup!!!\n",howmany);
   tout_val.it_interval.tv_sec = 0;
   tout_val.it_interval.tv_usec = 0;
   tout_val.it_value.tv_sec = INTERVAL; 
   tout_val.it_value.tv_usec = 0;
   
   setitimer(ITIMER_REAL, &tout_val,0);
   
}

void exit_func (int i)
{
    signal(SIGINT,exit_func);
    printf("\nBye Bye!!!\n");
    exit(0);
}

int main ()
{
  struct itimerval tout_val;
  
  tout_val.it_interval.tv_sec = 0;
  tout_val.it_interval.tv_usec = 0;
  tout_val.it_value.tv_sec = INTERVAL; 
  tout_val.it_value.tv_usec = 0;
  setitimer(ITIMER_REAL, &tout_val,0);

  signal(SIGALRM,alarm_wakeup); /* set the Alarm signal capture */
  signal(SIGINT,exit_func);
  
  while (1)
  {
    //printf("!");
  }
  
  return 0;

}