As of MDD v1.5.0, only ATmega16 and ATmega328P (=Arduino Uno) are supported. The code can easily be extended, but requires checking the data sheets in order to write to the correct bits.
So far only known to work with OpenModelica's ExperimentalEmbeddedC code generation. However, in principle it should work similarly with other (low foot-print) code generators.
OpenModelica v1.12.0 includes an experimental code generator for low footprint code. The code generator supports a subset of the Modelica language which will be extended in future versions. The current version is capable of translating the examples in the subpackages, but it is not as automated (no generation of makefiles) and it has been only tested using Linux as the host system. The basics are described in the initial AVR pull request #169, but the description below aims to be a bit more complete.
Using an Ubuntu Linux, following packages are required:
sudo apt-get install gcc-avr sudo apt-get install avr-libc sudo apt-get install avrdude
For the translation it is convenient to use the OpenModelica scripting interface and
collect the commands in a MOS file, e.g., named
runMDDAvr.mos
:
loadModel(Modelica); getErrorString(); loadFile("/path_to_MDD/Modelica_DeviceDrivers/package.mo"); getErrorString(); translateModel(Modelica_DeviceDrivers.EmbeddedTargets.AVR.Examples.Arduino.UNO.Blink, fileNamePrefix="Blink"); getErrorString();
Put the runMDDAvr.mos
file in a (build) directory and execute following commands on the command line:
omc --simCodeTarget=ExperimentalEmbeddedC runMDDAvr.mos avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections Blink_main.c -o Blink -I /path_to_MDD/Modelica_DeviceDrivers/Resources/Include -I /usr/include/omc/c avr-objcopy -O ihex -R .eeprom Blink Blink.hex avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:Blink.hex
The steps can also be mechanized in a Makefile, e.g., the Blink example comes with a Makefile, so one can simply do:
cd /path_to_MDD/Modelica_DeviceDrivers/Resources/Scripts/OpenModelica/EmbeddedTargets/AVR/Examples/Arduino/Uno/Blink make make flash
Name | Description |
---|---|
Blocks | |
Functions | |
Constants | |
Types | |
Examples |