PDA

View Full Version : DIV32 Questions ...



Acetronics2
- 20th August 2007, 10:00
Hi,

For my last hair sake ...

The attached program ( 18F452 @ 4 Mhz ) / PbP 2.47 / MPLAB 7.61a is a RPM counter for 4 Stroke 1 cyl engines ...

Based on Period Measuring ( w/ TMR3 ) and DT instant interrupts.

What goes wrong is the DIV32 calculation ... I've verified everything before: period is good, period measurement is right , Stable, and all data furnished to DIV 32 are "legal" ...

But result is quite FALSE !!!

The worse thing is I have successfully used DIV32 very often !!!

Placing DIV32 outside the interrupt stubb gives the same results, even when cancelling interrupts while Dummy and DIV calculating ...

I'm certainly missing something ... but what ???

Thanks to our gurus

Alain

PS for DARREL: All other parts of the lawn tractor computer work well ... just missing this part !!! Grrrrrr !!!

Darrel Taylor
- 20th August 2007, 10:30
Dummy = 2500*3000 'Prédiviseur à 8 !!!
Vitesse = DIV32 Periode2


The constants are being multiplied at Compile Time. So the system registers don't have the values they would if it were multiplied at Run Time.

If at least one of the numbers is in a WORD variable, it should work better.
<br>

jpohl
- 9th November 2007, 22:23
Hi Darrel,

just a question about the use of DIV32 instructions in the same program with your great instant interrupts lib.

In the documentation one can read the necessary use of disable/enable command before and after the DIV32 instructions.
Should I use also disable/enable in my program even there is no "On Interrupt" instruction? I use a timer and RBC interrupt via your interrupt interface.

Thanks in Advance.
Joerg

Darrel Taylor
- 9th November 2007, 22:45
Hi Joerg,

Nope, no need to disable interrupts when using DIV32 with DT_INTS.
System variables are saved and restored on each Interrupt.

ON INTERRUPT GOTO doesn't do that, so it has problems.

Good question though.
<br>

jpohl
- 9th November 2007, 23:01
Hi Darrel,

very good, thank you for your very fast reply.

Best Regards,
Joerg

Brock
- 10th November 2007, 00:49
Your code doesn't resemble the code example in the manual:

b = 500
c = 1000
dummy = b * c
a = DIV32 100

Your code:

Periode2 = Periode / 2
Dummy = 2500*3000
Vitesse = DIV32 Periode2

The right numbers are not on the stack when the DIV32 occurs.