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

> >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;
> >}
> >
> Your order of arithmetic is wrong.  Change to:
> 
> PWM_MR4 = (PWM_MR0 *DC1)/100;
> 
Yes, correct. I loose precision when I first devide and then
multiply.I altered  it as you specified here but still the problem
seems to be using the variable DC1. The outpui-value is continuously
high (100% DC). It does not seem to be allowed to use DC1 in this
function!!!?

I use gnu-arm 3.4.3.

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.