[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cascaded timers



i tried the volatile thing, but it didn't work. Actually, if i read the
couter TIMER01_DATA, i get jumps of 256 counts always (which is 40us at
6250kHz), which makes me suspect that I'm reading only the lower/higher
order byte at the address...

what I tried was very simple: 

void do_gettimeofday(struct timeval *tv)
{
        tv->tv_sec=*((volatile unsigned short *)R_TIMER01_DATA);
        tv->tv_usec=0;
        
}
so I simply store the counter values in tv. 
infact, i even tried reading timer0 into tv->tv_sec, and timer1 into
tv->tv_usec, and they are both always the same, and when they increment,
they increment by 1 ....so maybe the addresses are setup wrong? 
or could there be something wrong with the configuration of the timers?
This is what I use right now:


#ifdef USE_CASCADE_TIMERS
        *R_TIMER_CTRL =
                IO_FIELD( R_TIMER_CTRL, timerdiv1, 0) |
                IO_FIELD( R_TIMER_CTRL, timerdiv0, 244) |
                IO_STATE( R_TIMER_CTRL, i1, nop) |
                IO_STATE( R_TIMER_CTRL, tm1, stop_ld) |
                IO_STATE( R_TIMER_CTRL, clksel1, cascade0) |
                IO_STATE( R_TIMER_CTRL, i0, nop) |
                IO_STATE( R_TIMER_CTRL, tm0, stop_ld) |
                IO_STATE( R_TIMER_CTRL, clksel0, c6250kHz);

        *R_TIMER_CTRL = r_timer_ctrl_shadow =
                IO_FIELD( R_TIMER_CTRL, timerdiv1, 0) |
                IO_FIELD( R_TIMER_CTRL, timerdiv0, 244) |
                IO_STATE( R_TIMER_CTRL, i1, nop) |
                IO_STATE( R_TIMER_CTRL, tm1, run) |
                IO_STATE( R_TIMER_CTRL, clksel1, cascade0) |
                IO_STATE( R_TIMER_CTRL, i0, nop) |
                IO_STATE( R_TIMER_CTRL, tm0, run) |		IO_STATE(
R_TIMER_CTRL, clksel0, c6250kHz);
#else


timer0 is set to interrupt at 244, so that i get a near 10ms interrupt
(but changing it to anything else didnt make a difference)..

thanks,
akshay




Akshay Adhikari wrote:
> 
> i tried using cascade mode for the timers in kernel 2.4.14, running the
> combined 16-bit timer at 6250kHz to get better precision than 52 us. I
> know that kernel 2.4.19 has microsecond precision timing using the
> prescaler, so I should be able to get it using cascaded mode timers
> also. However, if I try reading (unsigned short)(*R_TIMER01_DATA), I get
> updated values only every 40us. What could be wrong?
> 
> thanks,
> akshay