When I open a C example code (blinking) for MCU C8051F38x from simplicity studio and compile this example code I have no error and it compile correctly.
I wanted to add U8 and U16 variable in this C example code and I got error C129
I think that the compiler don't know what is U8 and U16...
But in some other C code that I created long time ago, I know that all my C code compiled with U8 and U16 var.
I will try to describe my problem with a example, I will use the blinking example C code provided by simplicity studio for MCU C8051F38x :
When I create a new blinking example C code, and, I change nothing, it compile correctly.
After, I add variable "U8 tmp = 5;" for example, I try to compile and I got compilation error.
When I replace "U8 tmp = 5;" by "uint8_t tmp = 5;", I try to compile and it compile correctly.
When I want to add for example variable "U16 tmp = 10;" I have compilation error too.
What can be the problem ?
Why U8 and U16 is an error for this C compiler ?
Is U8 and uint8_t same/equivalent ?
Regards,
Nikola
Discussion Forums
Simplicity Studio
Answered
Answered
Hi Nikola,
I would say that the tool used with the project created a long time ago had a different "stdint.h" file. With Simplicity Studio projects, from the project explorer window, if you expand [Includes] > [C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/8051/v4.1.7/Device/shared/s8051Base] you should see the file stdint.h and if you open it you will see the typedefs for uint8_t and uint16_t, but not U8 or U16. If you have a codebase that depends on those values, you can add equivalent typedefs there or elsewhere in your code so that U8 will be equivalent to uint8_t.
The uint8_t and uint16_t are the values used by later versions of the C standard, I believe they were introduced with C99.
I hope this helps.
Thank you,
jpitt
Correct Answer
0
Dear Jpitt,
thank you for your answer, it help me a lot.
I solved this error by adding in my code (and not in stdint.h) :
-typedef uint8_t U8
-typedef uint16_t U16
With this 2 added typedef I have not compilation error for U8 and U16.
But, now, I have other errors, and I think it is again a problem of C standard version as you metioned...
Here is "typedef" of the "old C standard version" which compiler creates errors :
SBIT (SDA0_i2c_sbit, SFR_P0, 0)
SBIT (SCL0_i2c_sbit, SFR_P0, 1)
INTERRUPT(SMBUS0_ISR, SMBUS0_IRQn)
INTERRUPT(TIMER3_ISR, TIMER3_IRQn)
Do you know what can be the equivalent for the new C standard version for "SBIT" and "INTERRUPT" ?
The MCU used for this project is : C8051F380
The SDK / C compiler installed and used in this simply studio project is :
Keil 8051 v9.60.0 (previously, the project was created with version Keil V9.53)
8051 SDK v4.1.7.0 (previously, the project was created with version 8051 SDK v4.1.5)
Maybe the best way to solve this compilation error for this project is to download and configure "older" C compiler/SDK...
Do you know if it is possible to use "older" C compiler/SDK ?
Where can I download "older" C compiler/SDK ?
How can I configure simplicity studio to use these "older" C compiler/SDK ?
Regards,
Nikola
0
Hi Nikola,
In the same directory that contains the stdint.h directory you will find 'si_toolchain.h' that contains the updated equivalents you are looking for for BIT and INTERRUPT, since this are Silicon Labs extensions, the new versions have an 'SI_' prefix - so SI_SBIT and SI_INTERRUPT.
For your other question it is possible to install the older SDK version and the older toolchain using the Simplicity Studio Installation Manager.
1. To install the Keil 9.53 toolchain from the Launcher perspective select [Update Software] > [Package Manager] and then select the [Tools] tab, scroll to the bottom of the window to the Toolchains section and click the install link for [Keil 8051 Toolchain (v9.53)].
2. To install 8051 SDK v4.1.5 from the Launcher perspective select [Update Software] > [Package Manager] and then select the [SDKs] tab, change the left Categories filter to [8051] and the middle [Version] filter to [All] and you will be able to install any of the older 8051 SDKs supported by Simplicity Studio 4.
3. Installed SDKs and toolchains can be enabled or disabled from the SDKs and Toolchain preference pages under [Window] > [Preferences] > [Simplicity Studio]. If the newer SDK and Toolchain are disabled, then when a new project is created it will use the older enabled packages. The SDK to use can also be set from the Launcher perspective, select your target part in either the [Debug Adapters] or [My Products] window and then the [here] link to change the preferred SDK to version 4.1.5:
The toolchain version is associated with the build configuration, when creating a new project the last dialog box allows the desired build configurations to be selected and the project will start out using the one with (active) after it :
To add a new build configuration for existing projects, right click on the project folder and select [Build Configurations] > [Manage...] and then [New...] select the build configuration(s) to add and click [OK]
You can then select the new build configuration in the [Manage Build Configurations] dialog and click [Set Active] to switch to it.
Hopefully this answers all your questions.
Thank you,
jpitt
1
Hi Jpitt,
thank you, your explanation helped me a lot.
My problem is solved.
U8 U16 variable make compilation error C129
Dear all,
When I open a C example code (blinking) for MCU C8051F38x from simplicity studio and compile this example code I have no error and it compile correctly.
I wanted to add U8 and U16 variable in this C example code and I got error C129
I think that the compiler don't know what is U8 and U16...
But in some other C code that I created long time ago, I know that all my C code compiled with U8 and U16 var.
I will try to describe my problem with a example, I will use the blinking example C code provided by simplicity studio for MCU C8051F38x :
When I create a new blinking example C code, and, I change nothing, it compile correctly.
After, I add variable "U8 tmp = 5;" for example, I try to compile and I got compilation error.
When I replace "U8 tmp = 5;" by "uint8_t tmp = 5;", I try to compile and it compile correctly.
When I want to add for example variable "U16 tmp = 10;" I have compilation error too.
What can be the problem ?
Why U8 and U16 is an error for this C compiler ?
Is U8 and uint8_t same/equivalent ?
Regards,
Nikola
Hi Nikola,
I would say that the tool used with the project created a long time ago had a different "stdint.h" file. With Simplicity Studio projects, from the project explorer window, if you expand [Includes] > [C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/8051/v4.1.7/Device/shared/s8051Base] you should see the file stdint.h and if you open it you will see the typedefs for uint8_t and uint16_t, but not U8 or U16. If you have a codebase that depends on those values, you can add equivalent typedefs there or elsewhere in your code so that U8 will be equivalent to uint8_t.
The uint8_t and uint16_t are the values used by later versions of the C standard, I believe they were introduced with C99.
I hope this helps.
Thank you,
jpitt
Dear Jpitt,
thank you for your answer, it help me a lot.
I solved this error by adding in my code (and not in stdint.h) :
-typedef uint8_t U8
-typedef uint16_t U16
With this 2 added typedef I have not compilation error for U8 and U16.
But, now, I have other errors, and I think it is again a problem of C standard version as you metioned...
Here is "typedef" of the "old C standard version" which compiler creates errors :
SBIT (SDA0_i2c_sbit, SFR_P0, 0)
SBIT (SCL0_i2c_sbit, SFR_P0, 1)
INTERRUPT(SMBUS0_ISR, SMBUS0_IRQn)
INTERRUPT(TIMER3_ISR, TIMER3_IRQn)
Do you know what can be the equivalent for the new C standard version for "SBIT" and "INTERRUPT" ?
The MCU used for this project is : C8051F380
The SDK / C compiler installed and used in this simply studio project is :
Keil 8051 v9.60.0 (previously, the project was created with version Keil V9.53)
8051 SDK v4.1.7.0 (previously, the project was created with version 8051 SDK v4.1.5)
Maybe the best way to solve this compilation error for this project is to download and configure "older" C compiler/SDK...
Do you know if it is possible to use "older" C compiler/SDK ?
Where can I download "older" C compiler/SDK ?
How can I configure simplicity studio to use these "older" C compiler/SDK ?
Regards,
Nikola
Hi Nikola,
In the same directory that contains the stdint.h directory you will find 'si_toolchain.h' that contains the updated equivalents you are looking for for BIT and INTERRUPT, since this are Silicon Labs extensions, the new versions have an 'SI_' prefix - so SI_SBIT and SI_INTERRUPT.
For your other question it is possible to install the older SDK version and the older toolchain using the Simplicity Studio Installation Manager.
1. To install the Keil 9.53 toolchain from the Launcher perspective select [Update Software] > [Package Manager] and then select the [Tools] tab, scroll to the bottom of the window to the Toolchains section and click the install link for [Keil 8051 Toolchain (v9.53)].
2. To install 8051 SDK v4.1.5 from the Launcher perspective select [Update Software] > [Package Manager] and then select the [SDKs] tab, change the left Categories filter to [8051] and the middle [Version] filter to [All] and you will be able to install any of the older 8051 SDKs supported by Simplicity Studio 4.
3. Installed SDKs and toolchains can be enabled or disabled from the SDKs and Toolchain preference pages under [Window] > [Preferences] > [Simplicity Studio]. If the newer SDK and Toolchain are disabled, then when a new project is created it will use the older enabled packages. The SDK to use can also be set from the Launcher perspective, select your target part in either the [Debug Adapters] or [My Products] window and then the [here] link to change the preferred SDK to version 4.1.5:
The toolchain version is associated with the build configuration, when creating a new project the last dialog box allows the desired build configurations to be selected and the project will start out using the one with (active) after it :
To add a new build configuration for existing projects, right click on the project folder and select [Build Configurations] > [Manage...] and then [New...] select the build configuration(s) to add and click [OK]
You can then select the new build configuration in the [Manage Build Configurations] dialog and click [Set Active] to switch to it.
Hopefully this answers all your questions.
Thank you,
jpitt
thank you, your explanation helped me a lot.
My problem is solved.
Regards,
Nikola