Not Allocated function parameter

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not Allocated function parameter

Jump to solution
776 Views
tnriley
Contributor III

I am using CodeWarrior 5.1 Special Edition and am having trouble passing a value to a function.

 

The call from main()

setLEDDutyCycle(ATD1DR2L);

(Value of ATD1DR2L = 0xA0) as read from an external pot.

 

The function is as follows:

static void setLEDDutyCycle(uint8_t dc){

   PWMCTY5 = dc;

   PWMDTY4 = dc;

}

 

When stepping through the function in the Simulator/Debugger the value of the local variable dc in the DATA1 window shows as

dc   <not allocated>  unsigned char

 

Other functions that I have are working, but confused about this one.

 

Any ideas where I am off track?

Labels (1)
Tags (1)
0 Kudos
1 Solution
607 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tim,

For in the function of "setLEDDutyCycle()" , dc do nothing , only be given to other variable or

register , so  the compiler optimize it .

For example add  dc++; in that function , it will not optimize it .

Hope it helps
Have a great day,
Alice Yang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

4 Replies
607 Views
tnriley
Contributor III

Alice,

Sorry that was a typo it is actually PWMDTY5 which is the PWM Duty Cycle Register 5 as defined in MC9S12XDP512.h.

The problem though is why is dc not assigned the value passed as the function argument. 

When stepping through the function in the Simulator/Debugger the value of the local variable dc in the DATA1 window shows as

dc   <not allocated>  unsigned char

The call from main()

setLEDDutyCycle(ATD1DR2L);

(Value of ATD1DR2L = 0xA0) as read from the Data->Locals window.

0 Kudos
608 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tim,

For in the function of "setLEDDutyCycle()" , dc do nothing , only be given to other variable or

register , so  the compiler optimize it .

For example add  dc++; in that function , it will not optimize it .

Hope it helps
Have a great day,
Alice Yang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

607 Views
tnriley
Contributor III

Alice,

Interesting, but dc is passed in and is being used to set PWM port parameters. In all cases the code executed properly as indicated by the ability to set the LED brightness from the pot attached to ATD1DR2L.

So the IDE optimized it to <NULL> basically? I did the following to test.

1) Tried to declare as volatile in the parameter listing - Same result

2) Added the statement dc %= 0xff; - Same result

3) Added the statement dc++; before dc %= 0xff; - dc is now assigned the passed value in the Data1 -Locals window.

 

However the only time the correct passed value shows up in the Data1-Locals window is when the value is incremented.

Thanks

0 Kudos
607 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tim,

What about the type of  PWMCTY5 ?

Could you please share your project , or there is some confidential about the project,

you can delete some code , then only remain the code which can show the error .

BR

Alice

0 Kudos