[uCsimm] A: How to free the General Purpose Timer

From: Matthias Schoeldgen (m.schoeldgen@b-cool.de)
Date: Sat Jan 27 2001 - 08:00:55 EST


I needed the general purpose timer for my robotics project , so I
decided to use the sampling frequency irq of the already running
realtime clock. The sampling frequency of 128 Hz seemed close enough.
Here the code snippet in config.c

void BSP_sched_init(void (*timer_routine)(int, void *, struct pt_regs
*))
{
#ifdef 0 /* Matthias : Use the RTC instead */
  /* Restart mode, Enable int, 32KHz, Enable timer */
  TCTL = TCTL_OM | TCTL_IRQEN | TCTL_CLKSOURCE_32KHZ | TCTL_TEN;
  /* Set prescaler (Divide 32KHz by 32)*/
  TPRER = 31;
  /* Set compare register 32Khz / 32 / 10 = 100 */
  TCMP =
10;
#endif
/* is already running, just ignite the irq */
    RTCIENR |= RTCIENR_SAM5; /* select the SAM5 frequncy */
    RTCISR = RTCISR_SAM5 ; /* clear pending (if any) now */
/* IRQ 22 is the MSAM in the IMR */
  request_irq(IRQ_MACHSPEC | 22, timer_routine, IRQ_FLG_LOCK, "timer",
NULL);
}

void BSP_tick(void)
{
        /* Reset IRQ source */
    RTCISR = RTCISR_SAM5 ; /* clear irq source */
}

Remember to change the HZ in params.h for both CONFIG_MZ68EZ328 and
CONFIG_UCSIMM to 128. I still get some confusing results in "ps" , but
it works. If someone knows it better, please let me know

Matthias
This message resent by the ucsimm@uclinux.com list server http://www.uClinux.com/



This archive was generated by hypermail 2b30 : Sun Apr 07 2002 - 00:01:40 EST