Yahoo Groups archive

Lpc2000

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

Message

Re: float in interrupt function?

2005-04-08 by ed_hage

Hello Dan,

thank you for the info.
That is a good and simple way to avoid floats. 

The only thing that I can not get done is to use a global variable to
multiply (the global is being updated by other functions like
controller-function).

I changed to the following but it still does not work:

//global
int DC1 = 80; // 80%

void IRQMotorOut (void)
{
  PWM_MR4 = PWM_MR0 / 100; 
  PWM_MR4 *= DC1;   // 0<DC1<100 [%] 
  PWM_IR = PWM_RESET_MR0; //clear flag
  PWM_TCR = (1<<1);
  PWM_TCR=(1<<0);
  VICVectAddr = 0;
}

What could I be doing wrong?

--- In lpc2000@yahoogroups.com, "Dan Beadle" <dan.beadle@i...> wrote:
> In general, try to keep interrupt functions short and sweet.  Floating

> 
> PWM_MR4 = PWM_MR0*8;
> 
> PWM_MR4 /=10;
> 
> The in-line integer math will run much faster.  And then you don't
have to
> worry about library calls from interrupts, library reentrancy, etc. 
> 
>  
> float DC1 = 0.800;
> 
> void IRQMotorOut (void)
> {
>   PWM_MR4 =  ((unsigned long) (DC1 * PWM_MR0));  
>   PWM_MR6 = 0.8*PWM_MR0; 
>   PWM_IR = PWM_RESET_MR0; //clear flag
>   VICVectAddr = 0;
> }
>

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.