Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pinguino timer library
17-02-2012, 04:08 PM, (This post was last modified: 17-02-2012, 07:11 PM by samuele.)
#1
Pinguino timer library
Hello,
I created a timer library for Pinguino that it allows
to manage a different asynchronous task.
The zip file contains the library,pde file, one example
and readme file for installation.
It's recommended for expert user because if you
want to install it, you have to write a code line in
main.c source file.
For bugs leave a reply Smile
Samuele.


Attached Files
.zip   timer.zip (Size: 1.58 KB / Downloads: 26)
Reply
17-02-2012, 06:39 PM,
#2
RE: Pinguino timer library
Looks useful!

I can't actually test it, sorry, but maybe:

add volatile to _interval and I suppose _target

I can't see the reason to limit interval & freq (other than to avoid divide by zero). It looks as though a minimum of one tick more than may be wanted is enforced (you check _cnt<_interval).

the magic numbers like 0xE8 and 0x50 could perhaps be #define e.g.
#define TIMERCNT 0xE850
etc (and why E850?)

I'm puzzled that both timer_rri() and timer_irr() are used. A typo?

John
Reply
17-02-2012, 07:09 PM, (This post was last modified: 17-02-2012, 07:13 PM by samuele.)
#3
RE: Pinguino timer library
(17-02-2012, 06:39 PM)pingotg Wrote: Looks useful!

I can't actually test it, sorry, but maybe:

add volatile to _interval and I suppose _target

I can't see the reason to limit interval & freq (other than to avoid divide by zero). It looks as though a minimum of one tick more than may be wanted is enforced (you check _cnt<_interval).

the magic numbers like 0xE8 and 0x50 could perhaps be #define e.g.
#define TIMERCNT 0xE850
etc (and why E850?)

I'm puzzled that both timer_rri() and timer_irr() are used. A typo?

John

Thanks, but "volatile" before an attribute means that the variabile can
be modified simultaneously by two functions, _interval and _target are changed at most by a single function.
For interrupt_irr and interrupt_rri sorry but was a typo Smile
The reason to limit interval is to avoid overflow and division by zero but you can
delete the "if" test if you want to Smile


README file corrected Smile

Reply
17-02-2012, 07:46 PM,
#4
RE: Pinguino timer library
volatile is also used where a value may be changing that is also being read by another piece of code.

Such as: _target being part set to a new value when the timer interrupts and a mixture of old and new _target read out and called. Crash.

John
Reply
17-02-2012, 07:50 PM,
#5
RE: Pinguino timer library
(17-02-2012, 07:46 PM)pingotg Wrote: volatile is also used where a value may be changing that is also being read by another piece of code.

Such as: _target being part set to a new value when the timer interrupts and a mixture of old and new _target read out and called. Crash.

John

Exactly but _target it's a function pointer not a value.
Samuele.
Reply
17-02-2012, 10:05 PM,
#6
RE: Pinguino timer library
It's more than one byte so what I said applies. It doesn't matter what the data is.

John
Reply
20-11-2012, 02:01 PM,
#7
RE: Pinguino timer library
(17-02-2012, 04:08 PM)samuele Wrote: Hello,
I created a timer library for Pinguino that it allows
to manage a different asynchronous task.
The zip file contains the library,pde file, one example
and readme file for installation.
It's recommended for expert user because if you
want to install it, you have to write a code line in
main.c source file.
For bugs leave a reply Smile
Samuele.

Thanks Samuele, I am gonna probe it as soon as possible. I usually use "Ontimer0" function for Pinguino8 (18F2550). In fact I have a problem with it. So my question is:

¿Could I use "delay" in for example a "loop" function and still receiving interrupts? Or during a delay there is no interrupt. I ask it before with "Ontimer0" I don't receive interrupts during a delay.

Thanks again.
Reply
20-11-2012, 04:08 PM,
#8
RE: Pinguino timer library
Interrupts are normally enabled so a delay should still allow interrupts.

John
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)