Table of Contents
Starting with Usercode
MRS modules like the CC16WP can be used in a variety of ways and combinations for many different applications. These applications can involve any combination of analog I/O, digital I/O, CAN- and LIN messaging, and time based triggers. A lot, but not all of this functionality is available through the Graphical Programming. For some users especially those experienced in software development using C, the most powerful way to combine all of these features is to program in usercode
.
The usercode can be opened with any text editor, but it is recommended to use an editor or IDE with syntax highlighting like Visual Studio Code.
Open Usercode
For programming in C the usercode and the accompanying headerfile can be directly opened from Applics Studio using the buttons usercode.c
and usercode.h
in the main window.
Usercode can also be accesed through the filesystem. It is located in your projects directory, e.g. at the following path:
..Applics Studio\CC16WP_B_GettingStarted\src\ds\user
usercode.c
mainly consists of two main functions:
-
user_code_init()
for initializations on program start and -
usercode()
for the main loop
Several commonly used functions are described with an example in the comments. A more detailed description is available in the chapter User API.
Usercode Architecture
Program Flow
The graphic below shows the program execution flow of MRS S32K-based modules, graphcode, usercode and how and when analog to digital converting is triggered.
Note: Since Basic Software version 4.9.0 the initialization code will wait for one complete ADC cycle for all channels on start-up by default. This is to ensure that all ADC values are available inside usercode_init()
. This typically takes around 2 ms to finish.
In very specific cases on specific hardware like CC27WP it can take up to 90 ms due to hardware characteristics. Please contact support if you require faster boot times.
User Defined Sources
How to Include
Third party source files can be dropped into src/app/user_sources
and will be automatically added to the build. No additional steps are necessary. Every subdirectory will be considered as an include path and each .c or .cpp source file will generate an object file.
However advanced users get the opportunity to modify the makefile app_user.mk
to specify files or paths that should not be considered in the build (maybe for testing purposes).
Furthermore, should the path of the app
folder be modified, then the path variables in app.mk
and src.mk
have to be adjusted accordingly.

Be aware that these kind of changes will be deleted within a Applics Basis Software update.
Only the user_sources
subdirectory will not be deleted by Applics in any way (since AS v2.9.0).