Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: float in interrupt function?

2005-04-09 by ed_hage

Latest update:

When I reassign a value to DC1 in the function it works, example:

int DC1 = 90;

void IRQfunction (void)
{
  DC1 = 20;
  PWM_MR4 = (PWM_MR0 * DC1) / 100; 
  ... etc

Now I get a 20% DC, but when I comment out DC1 =20; I should get a 90%
DC (as specified before) but then I get a constant high output!!
How can I get the global to work?

(P.S. I also posted this question on the gnuarm group because I
suspect this may not be a typical LPC problem but maybe a gnu-issue)
 
> That's the point. I have it already running hard coded! I have a
> simular setup in a PWM_Init () function and I get great 5% DC on my
> output-pin  when I have the following:
> 
> PWM_MR4 = (PWM_MR0 * 5) / 100; 
> 
> Also tried (DC1 defined in the function):
> int DC1 = 5;
> PWM_MR4 = (PWM_MR0 * DC1) / 100; 
> 
> and that works, but what I want and does not work is defining DC1 as a
> global (outside the function) so I can change it with other functions.
> How can I solve this problem 
> 
> (we have evolved to a problem that has nothing to do with floats
> anymore ;-} )

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.