Yahoo Groups archive

Lpc2000

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

Message

RE: [lpc2000] Re: float in interrupt function?

2005-04-08 by Dan Beadle

I would first try hard coding MR4.    

 

I assume that you are in the Single Edge mode.  Verify that with fixed
numbers you have everything else set up, then come back to making MR4
variable based on MR0.

 

There are some details to setup - you have to set the PINSEL register to
make your pin and output on PWM.

 

Here is a code snippet from a project I am working on.  You PINSEL1 will
have to be a little different.

 

            PINSEL1 = 0x1540040E;                        // AIN, PWM5, MAT1,
MAT0

            PWMMR0 = PCLKFREQ/40000;             // Set 40khz.

            PWMMR5 = PWMMR0 / 2;                     // Set toggle point...

            PWMMCR = 2;                                      // Reset timer
on MR0

            PWMPCR = 0x2000;                              // Single Edge
mode, PWM5 Output...

            PWMPR  = 0;

            PWMTCR = 3;

            PWMTCR = 1;                                       // Start the
timer..

 

            PWMLER = 0x7f;                                   // Enable the
transfer...

 

This puts out 40khZ on PIN P0.21 (assuming 11.059 mhz clock, PLL not
enabled)

 

Hope this helps.

 

  _____  

From: ed_hage [mailto:ed_hage@...] 
Sent: Friday, April 08, 2005 4:06 PM
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: float in interrupt function?

 



> >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.






  _____  

Yahoo! Groups Links

*	To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
  
*	To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  
*	Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/>  Terms of Service. 



[Non-text portions of this message have been removed]

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.