RetroBSD

2.11BSD operating system for microcontrollers
It is currently Thu Sep 24, 2020 10:17 pm

All times are UTC




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Oct 09, 2015 4:52 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
With dl=100000 it works, but sometiimes shoots a nonsense..
Interestingly the us value does not increase from run to run, but caps at 500000 or so..
Code:
# ./tst
us1= 120177 ms1= 265871
us= 220348 ms= 265971
use= 100171 mse= 100
# ./tst
us1= 2297 ms1= 268974
us= 102470 ms= 269074
use= 100173 mse= 100
# ./tst
us1= 444255 ms1= 271563
us= 7555 ms= 271664
use= -436700 mse= 101
# ./tst
us1= 137142 ms1= 276088
us= 237314 ms= 276189
use= 100172 mse= 101
# ./tst
us1= 60214 ms1= 278696
us= 160387 ms= 278796
use= 100173 mse= 100
# ./tst
us1= 168309 ms1= 282025
us= 268479 ms= 282125
use= 100170 mse= 100
# ./tst
us1= 423037 ms1= 285501
us= 523210 ms= 285601
use= 100173 mse= 100
# ./tst
us1= 363291 ms1= 288125
us= 463463 ms= 288226
use= 100172 mse= 101
# ./tst
us1= 319384 ms1= 290766
us= 419554 ms= 290866
use= 100170 mse= 100
# ./tst
us1= 79583 ms1= 292674
us= 179756 ms= 292774
use= 100173 mse= 100
# ./tst
us1= 294937 ms1= 294500
us= 395156 ms= 294600
use= 100219 mse= 100
# ./tst
us1= 509069 ms1= 296324
us= 72368 ms= 296425
use= -436701 mse= 101
# ./tst
us1= 220338 ms1= 300331
us= 320511 ms= 300431
use= 100173 mse= 100
#

It seems
Code:
return (now * 2000 / cpu_khz());

runs over..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Fri Oct 09, 2015 5:08 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Code:
unsigned usecs()
{
    unsigned now = c0_count();
    return (now / 4);
}

unsigned msecs()
{
    unsigned now = c0_count();
    return (now / 4000);
}

Code:
# ./tst
us1= 6459180 ms1= 6459
us= 6559190 ms= 6559
use= 100010 mse= 100
# ./tst
us1= 8590852 ms1= 8590
us= 8690864 ms= 8690
use= 100012 mse= 100
# ./tst
us1= 10840483 ms1= 10840
us= 10940495 ms= 10940
use= 100012 mse= 100
# ./tst
us1= 12625535 ms1= 12625
us= 12725545 ms= 12725
use= 100010 mse= 100
# ./tst
us1= 14714437 ms1= 14714
us= 14814448 ms= 14814
use= 100011 mse= 100
# ./tst
us1= 16805040 ms1= 16805
us= 16905049 ms= 16905
use= 100009 mse= 100
#

Ok, we need long or a precalculated values for CPU_KHZ divided ot multiplied with somethong for all the calculations there..
A new topic will be started for udelay() and friends..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 8:17 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
majenko wrote:
Try this:

Code:
// testdel1.c
#include "delay.h"
extern void dodelay();

int main() {
    udelay(1000);
    dodelay();
    return 0;
}


Code:
// testdel2.c
#include "delay.h"

void dodelay() {
    udelay(1000);
}


Code:
$ cc -o tst testdel1.c testdel2.c

With static functions or not in the delay.h
Code:
# cc -o tst t1.c t2.c
t1.c:
t1.c:1: error: fastscan
t2.c:
#

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 10:27 am 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Not sure we have properly working static functions yet. Either way, it's a reason not to put functions in h files.

Functions go in C files not H files - you put the prototypes and extern references in the H file.

The only times you are allowed to put a function in a H file is if it's static and/or inline (and that functionality works on the compiler) or it's a templated member function for a class (and of course that means C++). So in summary, on RetroBSD - never ;)

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 11:17 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Ok, but still, when compiled a single xyz.c which includes the .h only once, I get the "out of macro space" error..
Ie.:
i2cscan.c includes i2c.h only (and i2c.h includes pins.h and delay.h only):
Code:
# cc -o i2cscan i2cscan.c
/include/sys/proc.h:82: error: out of macro space!
#

I've put everything into a single .c file and it still shoots the error.
It seems it is too big for the compiler when in one chunk..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Oct 11, 2015 12:49 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Ok, this is causing the trouble (in delay.h):

Code:
#include <sys/sysctl.h>
#include <machine/cpu.h>


I've split the delay.c into delay.h and delay.c and
Code:
# cc -o ics delay.c i2cscan.c
delay.c:
i2cscan.c:
#

It seems it works

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

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