Yahoo Groups archive

Lpc2000

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

Message

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

2005-04-09 by capiman@t-online.de

The "volatile" is the thing, which makes it worth trying out...

Regards,

         Martin

----- Original Message ----- 
From: "ed_hage" <ed_hage@...>
To: <lpc2000@yahoogroups.com>
Sent: Saturday, April 09, 2005 1:24 PM
Subject: [lpc2000] Re: float in interrupt function?


>
>
> I don't want to define DC1 = 20 inside the IRQfunction. That works
> already. I want to use the value of DC1 = 90 instead that is defined a
> a global,
>
> Already changed int to unsigned long because I also have defined some
> other variables that way which I can manipulate with another
> IRQfunction. But the results are the same.
>
> --- In lpc2000@yahoogroups.com, "charlesgrenz" <charles.grenz@s...> wrote:
>>
>> Hi guys, just a thought, try this instead
>>
>> volatile unsigned long DC1 = 90;
>>
>> void IRQfunction(void)
>> {
>>    DC1 = 20;
>>
>> }
>>
>> regards,
>> Charles
>>
>> --- In lpc2000@yahoogroups.com, "ed_hage" <ed_hage@y...> wrote:
>> >
>> > Latest update:
>> >
>> > When I reassign a value to DC1 in the function it works, example:
>> >
>> > int DC1 = 90;
>> >
>> > void IRQfunction (void)
>> > {
>> >   DC1 = 20;
>> >   PWM_MR4 = (PWM_MR0 * DC1) / 100;
>> >   ... etc
>> >
>> > Now I get a 20% DC, but when I comment out DC1 =20; I should get a 90%
>> > DC (as specified before) but then I get a constant high output!!
>> > How can I get the global to work?
>> >
>> > (P.S. I also posted this question on the gnuarm group because I
>> > suspect this may not be a typical LPC problem but maybe a gnu-issue)
>> >
>> > > That's the point. I have it already running hard coded! I have a
>> > > simular setup in a PWM_Init () function and I get great 5% DC on my
>> > > output-pin  when I have the following:
>> > >
>> > > PWM_MR4 = (PWM_MR0 * 5) / 100;
>> > >
>> > > Also tried (DC1 defined in the function):
>> > > int DC1 = 5;
>> > > PWM_MR4 = (PWM_MR0 * DC1) / 100;
>> > >
>> > > and that works, but what I want and does not work is defining
> DC1 as a
>> > > global (outside the function) so I can change it with other
> functions.
>> > > How can I solve this problem
>> > >
>> > > (we have evolved to a problem that has nothing to do with floats
>> > > anymore ;-} )
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>

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.