RetroBSD

2.11BSD operating system for microcontrollers
It is currently Thu Oct 17, 2019 4:17 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Feb 12, 2016 11:11 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Code:
struct timeval  time_info;
long tstart, tstop, elapsed;
long micros(){
   gettimeofday(&time_info, 0);
   return (time_info.tv_sec * 1000000L + time_info.tv_usec);
}


Why the time_info.tv_usec resolution is 10ms in RetroBSD, SmallerC?
Cannot be made better?

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Feb 13, 2016 12:13 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Precise interval measurement - maybe we shall run a 32bit hw timer, fed by 1MHz or something like that, and read via a syscall (micros()). That allows for 72minutes at 1us resolution.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Feb 13, 2016 8:06 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Pito,

I just read the CPU counter directly. Store that and do the math later. I suppose an interrupt routine could extend the counter to whatever number of digits makes sense for applications needing longer intervals.

Lots of fun :).

Wiz


Top
 Profile  
 
PostPosted: Sun Feb 14, 2016 10:42 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
You cannot read cpu tick timer directly.. Moreover it runs over in 107secs.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Feb 14, 2016 8:58 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Pito,

IIRC I did it with a syscall.

Wiz


Top
 Profile  
 
PostPosted: Fri Feb 19, 2016 6:50 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Pito wrote:
Why the time_info.tv_usec resolution is 10ms in RetroBSD, SmallerC?
Cannot be made better?

This problem has been solved in LiteBSD. A special machine-dependent routine microtime() is used to obtain a time value with microsecond precision. It should be pretty easy to back-port to RetroBSD kernel as well.


Top
 Profile  
 
PostPosted: Tue Feb 23, 2016 8:13 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
The retrobsd community would be happy if you may put that on your todo list, plz :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Nov 20, 2017 2:54 pm 

Joined: Thu Nov 09, 2017 11:52 am
Posts: 1
Has this issue been resolved? I remember I've had the same problem, but I stopped using the software soon after.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission