Delving into the Generated Code

MicrocontrollerEmbedCode returns a MicrocontrollerCodeData object that can be used to inspect the generated source code and probe other properties of the generated code.

Load the package.
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Use the "SourceCode" property to get the source code that was generated.

The source code.
In[3]:=
Click for copyable input
Out[3]=

Alternatively the source code can be sent to a specific working directory.

Create a temporary directory to put the source code.
In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=
The directory has the source code as well as other intermediate files.
In[6]:=
Click for copyable input
Out[6]=

While the source code provides the most complete information about all the generated code, you will also have to cross reference the microcontroller's datasheet to understand what the the specific settings of the microcontroller's registers mean.

Some of this information can be obtained upfront by using the properties.

The settings for serial communication.
In[7]:=
Click for copyable input
Out[7]=

Some other properties are specifications of the microcontroller for which the code was generated.

General microcontroller specifications.
In[8]:=
Click for copyable input
In[9]:=
Click for copyable input
Out[9]=

Other properties provide diagnostic information.

Data sent to standard error by the programmer.
In[10]:=
Click for copyable input
Out[10]=
The exit code.
In[11]:=
Click for copyable input
Out[11]=
The file sizes.
In[12]:=
Click for copyable input
In[13]:=
Click for copyable input
Out[13]=

All the available properties can be seen using the properties data.

All available properties.
In[14]:=
Click for copyable input
In[15]:=
Click for copyable input
Out[15]=
Not all properties are available in every case.
In[16]:=
Click for copyable input
Out[16]=