Hardware timer

KanyeKanye
Posts: 54
Joined: Mon Dec 05, 2016 12:34 am

Hardware timer

Postby KanyeKanye » Sat Mar 18, 2017 10:59 pm

CPU freq is 240MHz. Timer configuration is like the one below. I check if timer_val (from timer_get_counter_value) is larger than 36621 (36621 * 0xffff = 2 399 957 235). I believed it was 10seconds, but it seems to take more than 31 secs; why?
Are some timers used by WiFi or interface's (I2C, SPI, SDIO) drivers?

Code: Select all

	timer_config_t config;
	config.alarm_en = TIMER_ALARM_DIS;
	config.counter_en = TIMER_START;
	config.intr_type = TIMER_INTR_LEVEL;
	config.counter_dir = TIMER_COUNT_UP;
	config.auto_reload = TIMER_AUTORELOAD_DIS;
	config.divider = 0xffff;
	timer_init(TIMER_GROUP_0, TIMER_0, &config);
	timer_start(TIMER_GROUP_0, TIMER_0);


				uint64_t timer_val;
				timer_get_counter_value(TIMER_GROUP_0, TIMER_0, &timer_val);
				if (timer_val > 36621) { // should be 10 but is more than 31 secs
					...
				}

Hans Dorn
Posts: 62
Joined: Tue Feb 21, 2017 2:21 am

Re: Hardware timer

Postby Hans Dorn » Sat Mar 18, 2017 11:02 pm

The hardware timers are using an 80Mhz clock source.


Cheers
Hans

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], fanmen1, Vineethad and 254 guests