Customizing the Microcontroller
When generating code many parameters are automatically configured or based on default values. These can be modified by specifying them to the microcontroller.
|"Microcontroller"||microcontroller to generate code for|
|"OperatingVoltage"||operating voltage of the microcontroller|
|"ClockFrequency"||frequency of the microcontroller's system clock|
|"I2CAddress"||I2C address when operating as a I2C slave device|
|"SlaveSelect"||slave select pin when operating as a SPI slave device|
At each sampling instant the microcontroller reads the input signals, updates the states, computes the outputs, and sends the outputs out. When the sampling period is reached, the timer is reset and the process is repeated all over again. During each sampling period the microcontroller is busy for some time and idle for the remaining time, except if it has to deal with any interrupts that are triggered.
The sampling period can be a critical factor in determining the performance of the system. Choosing the sampling period is usually a tradeoff between performance and power consumption.
The information to set up the microcontoller to sample at each sampling instant can be found in its datasheet. By default, a timer and its parameters are automatically chosen. They can also explicitly set.
The following special values for timer can be specified.
|"delay"||uses the delay function from the Arduino library|
|"delayMicroseconds"||uses the delayMicroseconds function from the Arduino library|
|"millis"||uses the millis function from the Arduino library|
|"micros"||uses the micros function from the Arduino library|
The settings "delay", "delayMicroseconds", "millis" or "micros" uses functions from the Arduino libraries. The microcontroller first completes all its tasks, delays for τ seconds, and then starts all over again.
The setting None can be used for continuous operation. The new set of inputs are read immediately after the outputs are sent out. This can be used when the sampling period can be safely neglected. The timer is not set up in this case.
|"ADC"||A/D conversion specifications|
|"Serial"||serial communication specifications|
|"SerialOverUSB"||serial over USB specifications|
|"IncludeFiles"||files to include|
|"Definitions"||definition of macros|
|"Utilities"||utility functions and variables|
|"Loop"||execute at each sampling instant|
|"PreLoop"||execute before "Loop"|
|"PostLoop"||execute after "Loop"|
|"UntimedLoop"||execute repeatedly whenever the processor is free|
In some cases several pins, input, or output channels share a common functionality. For example, the analog to digital conversion is multiplexed among several input pins, or the same serial communication pins are used by several inputs and outputs. The setting in the microcontroller suboptions such as "ADC" and "Serial" will apply to all these channels.
Consider a system that has analog inputs and one output.
All the 3 inputs use AVCC as the reference value.
This common reference can be specified as a microcontroller suboption.
It may sometimes be possible to customize the functionality for an individual channel by specifying the setting directly for the channel.
Consider a setup where two MAX6675 thermocouples are reading data. They both use the same SPI bus, and the exchange sequences are also the same. However different pins are used to select them as slaves.
The utility to convert the bytes to a temperature value is also the same.
The input and output specifications are also the same, except for the slave select pins.
Since the utilities for by both thermocouples are the same, it can be given as a common utility code snippet that needs to be executed by the microcontroller.
Some microcontroller boards such as the Arduino Yun rely on being configured as a Communications Device Class (CDC) device to automatically upload new programs on to the board. This functionality also is useful during the operation of the device in cases such as virtual serial communication. With the "CDC" option you may choose to eliminate this functionality to reduce the program footprint and upload new programs by manually resetting the board.
|"Basic", Automatic||add basic CDC functionality|
|None||do not add CDC functionality|
Since removing the CDC functionality could result in the board going into a locked state, be sure of the consequences before evaluating the following inputs. If unsure, you can safely evaluate them without physically connecting the Arduino Yun.