Error with loading Arduino PWM library through Simulink. How can i fix it?

1 view (last 30 days)
I am trying to load PWM library to change the frequency of a PWM pin, on Arduino Mega 2560 with Simulink target by creating a S-Function block and i'm getting the following error. I'm trying for a long time to find an answer but i can't. Help requested!
The call to realtime_make_rtw_hook, during the after_make hook generated the following error:
The build failed with the following message: "C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" -I"C:/ArduinoLib/exapmle_rtt" -I"C:/ArduinoLib" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/extern/include" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/simulink/include" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/src" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/src/ext_mode/common" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/variants/mega" -I"C:/MATLAB/SupportPackages/R2015a/arduinobase/toolbox/realtime/targets/arduino/include" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/libraries/Servo" -mmcu=atmega2560 -ffunction-sections -fdata-sections -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=exapmle" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"ARDUINO=105" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_MEGA2560_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./ert_main.c ./exapmle.c ./exapmle_data.c ./sfPWM_wrapper.cpp ./HardwareSerial.cpp ./IPAddress.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp
In file included from ./ert_main.c:18:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./exapmle.h:22,
from ./ert_main.c:17:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
In file included from ./ert_main.c:18:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./exapmle.h:22,
from ./ert_main.c:17:
./rtwtypes.h:23:1: warning: this is the location of the previous definition
./ert_main.c: In function '__vector_50':
./ert_main.c:39: warning: implicit declaration of function 'rt_OneStep'
./ert_main.c: At top level:
./ert_main.c:46: warning: function declaration isn't a prototype
./ert_main.c:63: warning: conflicting types for 'rt_OneStep'
./ert_main.c:39: warning: previous implicit declaration of 'rt_OneStep' was here
./ert_main.c: In function 'rt_OneStep':
./ert_main.c:87: warning: 'eventFlags[0]' may be used uninitialized in this function
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./sfPWM_wrapper.cpp:16:1: warning: "ARDUINO" redefined
: warning: this is the location of the previous definition
In file included from ./sfPWM_wrapper.cpp:21:
C:/ArduinoLib/BTimerDefs.h:109:3: error: #error "BTimerDefs.h only supports ATMega48, ATMega88, ATMega168, ATMega328"
./sfPWM_wrapper.cpp: In function 'void sfPWM_Outputs_wrapper(const uint8_T*, const uint8_T*)':
./sfPWM_wrapper.cpp:52: error: 'PWM' was not declared in this scope
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
./HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressions
./HardwareSerial.cpp: In function 'void __vector_25()':
./HardwareSerial.cpp:127: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_36()':
./HardwareSerial.cpp:153: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_51()':
./HardwareSerial.cpp:168: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_54()':
./HardwareSerial.cpp:183: warning: unused variable 'c'
./HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':
./HardwareSerial.cpp:368: warning: unused variable 'current_config'
./HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
./HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressions
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
./Print.cpp:44: warning: '__progmem__' attribute ignored
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./io_wrappers.cpp: In function 'void Serial_read(int, int, uint8_t*, int16_t*)':
./io_wrappers.cpp:70: warning: 'libFcnOutput' may be used uninitialized in this function
make: *** [ert_main.o] Error 1
The build process will terminate as a result.
The build failed with the following message: "C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/tools/avr/bin/avr-gcc" -I"C:/ArduinoLib/exapmle_rtt" -I"C:/ArduinoLib" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/extern/include" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/simulink/include" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/src" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/src/ext_mode/common" -I"C:/Program Files/MATLAB/MATLAB Production Server/R2015a/rtw/c/ert" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/variants/mega" -I"C:/MATLAB/SupportPackages/R2015a/arduinobase/toolbox/realtime/targets/arduino/include" -I"C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/libraries/Servo" -mmcu=atmega2560 -ffunction-sections -fdata-sections -std=gnu99 -Wall -Wstrict-prototypes -g -Os -D"MODEL=exapmle" -D"NUMST=1" -D"NCSTATES=0" -D"HAVESTDIO=" -D"ONESTEPFCN=0" -D"TERMFCN=1" -D"MAT_FILE=0" -D"MULTI_INSTANCE_CODE=0" -D"INTEGER_CODE=0" -D"MT=0" -D"CLASSIC_INTERFACE=0" -D"ALLOCATIONFCN=0" -D"TID01EQ=0" -D"F_CPU=16000000" -D"ARDUINO=105" -D"_RUNONTARGETHARDWARE_BUILD_=" -D"_ROTH_MEGA2560_=" -D"_RTT_NUMSERVOS_=0" -c -x none ./ert_main.c ./exapmle.c ./exapmle_data.c ./sfPWM_wrapper.cpp ./HardwareSerial.cpp ./IPAddress.cpp ./Print.cpp ./WInterrupts.c ./WMath.cpp ./WString.cpp ./new.cpp ./wiring.c ./wiring_analog.c ./wiring_digital.c ./io_wrappers.cpp
In file included from ./ert_main.c:18:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:25:1: warning: "true" redefined
In file included from ./exapmle.h:22,
from ./ert_main.c:17:
./rtwtypes.h:27:1: warning: this is the location of the previous definition
In file included from ./ert_main.c:18:
C:/MATLAB/SupportPackages/R2015a/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:26:1: warning: "false" redefined
In file included from ./exapmle.h:22,
from ./ert_main.c:17:
./rtwtypes.h:23:1: warning: this is the location of the previous definition
./ert_main.c: In function '__vector_50':
./ert_main.c:39: warning: implicit declaration of function 'rt_OneStep'
./ert_main.c: At top level:
./ert_main.c:46: warning: function declaration isn't a prototype
./ert_main.c:63: warning: conflicting types for 'rt_OneStep'
./ert_main.c:39: warning: previous implicit declaration of 'rt_OneStep' was here
./ert_main.c: In function 'rt_OneStep':
./ert_main.c:87: warning: 'eventFlags[0]' may be used uninitialized in this function
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./sfPWM_wrapper.cpp:16:1: warning: "ARDUINO" redefined
: warning: this is the location of the previous definition
In file included from ./sfPWM_wrapper.cpp:21:
C:/ArduinoLib/BTimerDefs.h:109:3: error: #error "BTimerDefs.h only supports ATMega48, ATMega88, ATMega168, ATMega328"
./sfPWM_wrapper.cpp: In function 'void sfPWM_Outputs_wrapper(const uint8_T*, const uint8_T*)':
./sfPWM_wrapper.cpp:52: error: 'PWM' was not declared in this scope
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
./HardwareSerial.cpp:98: warning: comparison between signed and unsigned integer expressions
./HardwareSerial.cpp: In function 'void __vector_25()':
./HardwareSerial.cpp:127: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_36()':
./HardwareSerial.cpp:153: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_51()':
./HardwareSerial.cpp:168: warning: unused variable 'c'
./HardwareSerial.cpp: In function 'void __vector_54()':
./HardwareSerial.cpp:183: warning: unused variable 'c'
./HardwareSerial.cpp: In member function 'void HardwareSerial::begin(long unsigned int, byte)':
./HardwareSerial.cpp:368: warning: unused variable 'current_config'
./HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
./HardwareSerial.cpp:467: warning: comparison between signed and unsigned integer expressions
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
./Print.cpp:44: warning: '__progmem__' attribute ignored
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./io_wrappers.cpp: In function 'void Serial_read(int, int, uint8_t*, int16_t*)':
./io_wrappers.cpp:70: warning: 'libFcnOutput' may be used uninitialized in this function
make: *** [ert_main.o] Error 1

Answers (1)

Walter Roberson
Walter Roberson on 17 Jul 2015
There are multiple issues there, but regardless of the others, you have:
BTimerDefs.h only supports ATMega48, ATMega88, ATMega168, ATMega328
You are trying to build the software for an Arduino device that it is not designed to handle.

Communities

More Answers in the  Power Electronics Control

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!