2021-02-02 03:49 AM
HI, I am using Macro to set and clear my pin using stm32f103. This is the macro i defined
#define SET(PIN,N) (PIN |= (1<<N))
#define CLR(PIN,N) (PIN &= ~(1<<N))
where ,
i have done the code like,
if(Drive _Enabled==1)
{
Status _Register[2] = SET(1,0);
}
//Status _Register[2] = CLR(1,0);
if(drive_ motion _complete==1) //to read whether motion is complete or not
{
Status _Register[2] = SET(1,1);
}
but i am getting error can anyone help me how to solve this error and what i need to add to my code please.
i have attached the picture showing the error below.
Solved! Go to Solution.
2021-02-02 10:22 PM
Macros are not a good solution anyway.
Why not using inline functions ?
2021-02-02 04:56 AM
Always start inspection with the first error, which is not visible...
2021-02-02 07:42 PM
sorry , but i did not understood what you said . Please can you explain it to me .
Thank you
2021-02-02 09:46 PM
Scroll up the Console View such that the first lines are visible and make a new screen shot if you cannot decipher the first error message yourself.
2021-02-02 10:04 PM
please define your macros like this :
#define SET(PIN, N, OUT) (OUT = PIN | (1<<N))
#define CLR(PIN, N, OUT) (OUT = PIN & ~(1<<N))
You need an extra parameter (OUT) to store the rValue calculated by the macro function.
store OUT in your status register
2021-02-02 10:22 PM
Macros are not a good solution anyway.
Why not using inline functions ?
2021-02-02 10:26 PM
@Ozone I completely agree with you. Inline functions are always good to have rather than macros.
2021-02-05 08:24 PM
Thank you