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

Thanks for the explanation.

I defined it as volatile and really it still does not work.
--------------------------------------------------
volatile unsigned long	DC0 = 10;

void IRQMotorOut (void)
{
  PWM_MR4 = (PWM_MR0 * DC0) / 100; 
  PWM_MR6 = (PWM_MR0 * 80)  / 100; 
  PWM_IR = PWM_RESET_MR0; //clear flag
  PWM_TCR = (1<<1);
  PWM_TCR = (1<<0); 
  VICVectAddr = 0;
}
-------------------------------------------------
MR6 works great, MR4 not. MR4 will work if I put DC0 =20 inside the
function, but like this its hopeless.I run out of ideas of what it
could be solved.

> 
> When ever you use a global variable, you have to specify it as a
> volatile to tell the compiler not to opitmize the variable out of the
> equation when working with any ANSI C compiler.
> 
> Also by type casting the variable the same as the register you want to
> use makes sure that the compiler is not going to do something funky
> when optimization is performed no matter what level.
> 
> regards,
> Charles
> 
> --- In lpc2000@yahoogroups.com, capiman@t... wrote:
> > The "volatile" is the thing, which makes it worth trying out...
> >

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.