Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

OMAP L138 DSP 32 kHz timer counter register

$
0
0

I'm trying to write a gettimeofday() function to calculate the time from the RTC into:

struct timeval{
    unsigned int tv_sec;
    unsigned int tv_usec;
}

#define RTC_OSC_ADDR		 (0x01C23054) /* Address for OSC register */

int rtc_gettimeofday(struct timeval *tv){
	double usecPerClk = 30.517578125; /* (1000000/32767) OSC is a 32.767 kHz counter */
	double usecCalc;
	time_t secs;
	unsigned int oscVal;

	oscVal = HWREG(RTC_OSC_ADDR);

	time(&secs);
	usecCalc = (oscVal * usecPerClk);

	tv->tv_sec = (unsigned int)secs;
	tv->tv_usec = (unsigned int)usecCalc;

	return 0;
}

The value for tv_sec is trivial as I can use  time.h library with a time() glue function - this is working fine and I can see the time incrementing.

In order calculate the microseconds, tv_usec, I'm trying to read the value for the OSC register which I believe holds the value for the 32.768 kHz counter, however the value for oscVal in my code above just stays at a value of 7.

EDIT: I've re-read the documentation and it seems that the OSC register doesn't hold the value for the timer counter as I thought. I can't see anywhere that references this counter, except for the Figure 2 in the RTC user guide (page 12).

Does anyone know if / how I can read the value of the 32 kHz RTC counter?


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>