Hello Champs,
RT-linux: ti-processor-sdk-linux-rt-am57xx-evm-05.02.00.10-Linux-x86-Install.bin
Customer tested DMtimer according to below link.
1. System Clock is 20Mhz, when running below code, the timer is 2s.
priv->timer_ptr = omap_dm_timer_request_by_node(priv->dm_node);
/* Set the Clock source to the SystemClock *
omap_dm_timer_set_source(priv->timer_ptr, OMAP_TIMER_SRC_SYS_CLK);
/* Set prescaler to 1:1 */
omap_dm_timer_set_prescaler(priv->timer_ptr, 0);
/* Determine what IRQ the timer triggers *
priv->timer_irq = omap_dm_timer_get_irq(priv->timer_ptr);
/* Setup the IRQ handler *
ret = request_irq(priv->timer_irq, zhx_timer_irq_handler, IRQF_TIMER, DRIVER_NAME, priv);
system clock is
/* Get the Clock rate in Hz */
timer_clk = omap_dm_timer_get_fclk(priv->timer_ptr);
priv->timer_rate = clk_get_rate(timer_clk);
//此时打印出来该数值,priv->timer_rate为20Mhz。
priv->owner = task_pid_nr(current); //得到pid号
priv->current_task = pid_task(find_vpid(priv->owner), PIDTYPE_PID); //pid_task( )---根据pid获取task_struct
omap_dm_timer_enable(priv->timer_ptr);
omap_dm_timer_set_int_enable(priv->timer_ptr, OMAP_TIMER_INT_OVERFLOW); //使能溢出中断
When timer started, he configured priv->timer_ratio = arg; and then set the initialized value to timer. Timer will count from the initialized value, when it counts to 0x0xffffffff, it will count from the initialized value again.
omap_dm_timer_set_load_start(priv->timer_ptr, 1, 0xffffffff - (priv->timer_ratio * priv->timer_rate));
The priv->timer_rate from clk_get_rate() is 20M (printed by printk), it means the system clock is 20MHz. But when priv->timer_ratio is 1, 0xffffffff - priv->timer_rate, the timer period should be 1s, why it is still 2s?
Thanks.
Rgds
Shine