Why do I receive syntax errors in Simplicity Studio when defining an interrupt? The code compiles and works correctly, but declaring an interrupt, such as this one, gives a syntax error in Studio:
This occurs since Simplicity Studio uses a generic C syntax parser when looking for syntax errors in code. It doesn't understand compiler-specific C code, like that used by Keil C51 to define an interrupt function - the 'interrupt' keyword and interrupt number after the function declaration aren't standard C, so it throws a syntax error. Keil, however, when the project is compiled, understands this syntax and compiles the code correctly.
We have a work-around for this visual error by the way of macros in si_toolchain.h. If you use the SI_INTERRUPT(name, vector) macro, it will generate different declarations based on which tool is viewing the code. If __SLS_IDE__ is defined (that is, if the Simplicity Studio parser is looking at the code, it omits the interrupt vector number from the actual declaration. If Keil C51 is viewing the code, it places the vector number in the correct location for Keil to compile it correctly.
For example, if we used the following:
SI_INTERRUPT(INT1_ISR, 2)
In the IDE, this would generate:
void INT1_ISR (void)
But, for C51, this would generate:
void INT1_ISR (void) interrupt 2
This would eliminate the syntax error, but still allow Keil to compile the interrupt correctly.
I’m running Windows 10/Simplicity Studio 4 and I am trying to power my Silicon Labs device through the USB Debug Adapter (UDA), but the UDA keeps shutting off after I flash the device. What gives?
Answer:
The UDA configurator in Simplicity Studio 4 has the option of allowing the UDA to continue to provide power to the target device, even after disconnecting from a debug session. This is a setting in the UDA that attempts to maintain USB power through the USB host.
However, Windows has several additional USB “features” that will try to save power by shutting down what the OS deems as unnecessary USB devices. The first component, which is more user configurable, is called USB Selective Suspend. USB Selective Suspend allows the hub driver to suspend an individual port without affecting the operation of the other ports on the hub. There are many ways of disabling this feature, but for the scope of this article, we’ll stick with the user-friendly methodology.
On a global scale, you can disable USB Selective Suspend on all USB hubs/devices. Here’s how to do this in Windows 10:
Connect the USB Debug Adapter to the computer
Open the Power & Sleep settings window. To do this, type Power & Sleep in the Windows toolbar search bar, and then tap or click Power & Sleep in the search results.
In the settings window, scroll down and click Additional power settings.
In the power options window, click Change plan settings for the currently selected plan.
In the edit plan settings windows, click Change advanced power settings.
In the next power options window, open the tree labeled USB settings/USB selective suspend setting and change the settings to disabled.
To disable USB Selective Suspend on individual USB devices:
Connect the USB Debug Adapter to the computer
Open the Device Manager. To do this, type Device Manager in the Windows toolbar search bar, and then tap or click Device Manager in the search results.
To display the list of connected Human Interface Devices (HID), tap or click the arrow next to Human Interface Devices.
Find the USB Input Device associated with the UDA. To do this, right-click each item labeled USB Input Device and open up the device properties window. From here, select the Details tab and select Device instance path from the property drop-down list. Locate the device with the device instance path that includes VID_10C4 and either PID_8044 or PID_8045. This is the UDA. While here, make a note of the Instance ID, which is the unique identifier at the end of the device instance path (e.g. USB\VID_10C4&PID_8045\UDA000C5691)
Stay in the device’s property window, but navigate to the Power Management tab.
Uncheck the checkbox next to Allow the computer to turn off this device to save power.
For external ports (externally powered hubs), either of the previously described methods will enable the UDA to continue powering the target device even after disconnecting. However, for built in ports, there is an additional power management “improvement” introduced in Windows 8.1 and beyond which will suspend a USB Human Interface Device (HID) if there is not an application actively accessing it! To disable this feature, a value in the system registry needs to be changed.
Start Registry Editor. To do this, type regedit.exe in the Windows toolbar search bar, and then tap or click regedit in the search results.
In the navigation pane, find the registry key that corresponds to the problem device. To do this, follow these steps:
Tap or click the arrow next to the HKEY_LOCAL_MACHINE folder to expand it.
Expand SYSTEM.
Expand CurrentControlSet.
Expand Enum.
Expand USB.
Locate the folder whose name contains the VID and PID that you noted in step 6 (for example, locate VID_10C4&PID_8044 or VID10C4&PID_8045), and then expand that folder.
Expand the folder that matches the Instance ID from step 4 in the individual suspend disable walk-through above.
Tap or click Device Parameters.
In the details pane, right-click EnhancedPowerManagementEnabled, and then click Modify.
Change the Value data to 0, and then tap or click OK.
Exit Registry Editor.
The USB Debug Adapter will now stay powered, even after disconnecting from a debug session.
If for some reason you need to re-enable the Enhanced Power Management setting follow the same steps in the section above except that, in step 4, change the Value data back to 1.
8-bit Knowledge Base
Syntax error in Simplicity Studio when declaring interrupts?
Question:
Why do I receive syntax errors in Simplicity Studio when defining an interrupt? The code compiles and works correctly, but declaring an interrupt, such as this one, gives a syntax error in Studio:
Answer:
This occurs since Simplicity Studio uses a generic C syntax parser when looking for syntax errors in code. It doesn't understand compiler-specific C code, like that used by Keil C51 to define an interrupt function - the 'interrupt' keyword and interrupt number after the function declaration aren't standard C, so it throws a syntax error. Keil, however, when the project is compiled, understands this syntax and compiles the code correctly.
We have a work-around for this visual error by the way of macros in si_toolchain.h. If you use the SI_INTERRUPT(name, vector) macro, it will generate different declarations based on which tool is viewing the code. If __SLS_IDE__ is defined (that is, if the Simplicity Studio parser is looking at the code, it omits the interrupt vector number from the actual declaration. If Keil C51 is viewing the code, it places the vector number in the correct location for Keil to compile it correctly.
For example, if we used the following:
In the IDE, this would generate:
But, for C51, this would generate:
This would eliminate the syntax error, but still allow Keil to compile the interrupt correctly.
Powering Target Boards with a USB Debug Adapter does not work with Windows 10
Question:
I’m running Windows 10/Simplicity Studio 4 and I am trying to power my Silicon Labs device through the USB Debug Adapter (UDA), but the UDA keeps shutting off after I flash the device. What gives?
Answer:
The UDA configurator in Simplicity Studio 4 has the option of allowing the UDA to continue to provide power to the target device, even after disconnecting from a debug session. This is a setting in the UDA that attempts to maintain USB power through the USB host.
However, Windows has several additional USB “features” that will try to save power by shutting down what the OS deems as unnecessary USB devices. The first component, which is more user configurable, is called USB Selective Suspend. USB Selective Suspend allows the hub driver to suspend an individual port without affecting the operation of the other ports on the hub. There are many ways of disabling this feature, but for the scope of this article, we’ll stick with the user-friendly methodology.
On a global scale, you can disable USB Selective Suspend on all USB hubs/devices. Here’s how to do this in Windows 10:
To disable USB Selective Suspend on individual USB devices:
For external ports (externally powered hubs), either of the previously described methods will enable the UDA to continue powering the target device even after disconnecting. However, for built in ports, there is an additional power management “improvement” introduced in Windows 8.1 and beyond which will suspend a USB Human Interface Device (HID) if there is not an application actively accessing it! To disable this feature, a value in the system registry needs to be changed.
The USB Debug Adapter will now stay powered, even after disconnecting from a debug session.
If for some reason you need to re-enable the Enhanced Power Management setting follow the same steps in the section above except that, in step 4, change the Value data back to 1.