MATLAB: How to set Arduino TCCR1A and TCCR1B PWM-parameters in MATLAB

arduinoelectric_motor_controlMATLABmatlab arduino pwm tccr1a tccr1bpower_conversion_controlpower_electronics_control

Hello World,
It's needed to change Pulse-width modulation frequency on Arduino Board by Matlab, but could not find the way to do so.
In arduino coder it's perfectly realized by:
void setup()
{ TCCR1A = TCCR1A & 0xe0 | 1;
TCCR1B = TCCR1B & 0xe0 | 0x09;
}
but in MatLab?

Best Answer

In the Matlab Arduino package there is the file:
c:\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\arduinoio\src\ArduinoServer.ino
Modify it setup() function:
void setup()
{ MWArduino.begin([connection_type]);
TCCR1A = TCCR1A & 0xe0 | 1;
TCCR1B = TCCR1B & 0xe0 | 0x09;
}
Related Question