Yahoo Groups archive

Lpc2000

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

Message

float in interrupt function?

2005-04-08 by ed_hage

I am using a LPC2106-board from Olimex to drive two motors via PWM.

I have a simple interrupt-function for the PWM which reads the duty
cycle variable and then sets the DC. This does not work. In the
example beneath MR6 does give a good duty cycle (but is fixed!! so no
pracitcal use), and when I use the float DC1 (as in MR4) it does not
work. This is probably a problem which I may encounter more using
floats etc. What is the best known method to deal with this? (I am
newby in programming embedded ... as you might have guessed.

// single edge PWM 
//global
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.