On Tue, 24 Nov 2009, Frieder Ferlemann wrote:
> Hi Gordon,
>
> Gordon Henderson schrieb:
>> void mathTest (uint16_t x)
>> {
>> uint32_t y ;
>> uint32_t i = 0 ;
>>
>> for (;;)
>> {
>>
>> y = (uint32_t)x * 9668 + 500 ;
>> if (y != 4225416L)
>> {
>> serialPuts ("Curruption @ ") ;
>> ...
>> }
>> ++i ;
>>
>> }
>>
>> works fine with interrupts off, or with the math code in the interrupt
>> routine commented out, but sees random coruptions with them on:
>
> [..]
>
>> That's the first I've noticed int and I've not even dived into floating
>> point land yet...
>
> This does not really come as a surprise:
> The manual has a special section (3.9.1.4) Common interrupt pitfall
> which specifically mentions 16 bit and 32 bit arithmetics...
Indeed - however, when I asked about this a week or so back, I got the
impression that under the PIC16 port this was actually OK...
>> Any thoughts, anyone?
>
> First thought would be not to use math code within interrupts:)
Well, quite - however while I could code my application in a huge loop,
checking sensors, doing "stuff" @ every exact time interval required of
it, it will be so much easier under interrupts..
> Second thought, if you just need a multiply within interrupt,
> you could (taking multiply with 9668 (= 0x25c4) and add with 500 as example)
> get to the intended y by:
Thanks - but this is just the tip of the iceberg in one isolated case - I
need to do floating point. Lots of it... (And even if I could re-code it
in fixed-point, I'd still need to do lots of long multiplys and
divides...)
Gordon
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user