This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
Hi,
I enabled the MISRA C 2004 check from project properties and trying to make my motor control as comliant to MISRA C as possible.
Whenever i access a bitfield in the following format i get MISRA C warning.
GpioDataRegs.GPATOGGLE.bit.GPIO18=1; 'Description Resource Path Location Type #1393-D (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a wider integer type of the same signedness main.c /FOC line 213 C/C++ Problem '
How to avoid this warning?
Regards,
Shadab
If you are referring to MISRA warnings being generated on TI provided header files/related code, then yes they are not MISRA compliant and we do not have any plans to make them fully compliant. Depending on your requirement, you would need to modify the source code. Also some rules are mandatory, optional or case-by case.
Please see these related threads and document for reference.
https://e2e.ti.com/support/microcontrollers/c2000/f/171/p/524447/1907547#1907547
https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/783266
Of course, you *are* assigning an int to a bit, so the warning is valid. I don't even see any way to do a cast to shut it up. You might try true or false, which is allowed in C99.
You might try creating a constant bit field and assigning that, but that gets into doing something silly just to shut up a warning.
I tried the following:
GpioDataRegs.GPATOGGLE.bit.GPIO18=1u; /*added 'u' after one the warning is gone */
Is this valid? Will it affect the functionality of the code in any way?
Shadab Shaikh1 said:Is this valid?
Yes
Shadab Shaikh1 said:Will it affect the functionality of the code in any way?
No
Thanks and regards,
-George