4 years, 6 months ago.

RPC PWM doesn´t work in matlab

hello, I'm beginning (since yesterday) with mbed platform, I've got a LPC1768 and I'm trying to link it through RPC with matlab. I have already succesfully tested to blink a led and plot in matlab a variable from analog input but up to now I can't use a pwmout in RPC. here is the code, I hope someone can help me. thanks in advance.


  1. include "mbed.h"
  2. include "mbed_rpc.h"

accomodate read_u16() of AnalogIn template<> void Reply::putData<unsigned short>(unsigned short uint16) { separator(); reply += sprintf(reply, "%u", uint16); } /**

  • This example program has been updated to use the RPC implementation in the new mbed libraries.
  • This example demonstrates using RPC over serial
  • /

Use the RPC enabled wrapped class - see RpcClasses.h for more info RpcDigitalOut myled(LED4,"myled");

Serial pc(USBTX, USBRX); int main() { The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to base class

RPC::add_rpc_class<RpcAnalogIn>(); RPC::add_rpc_class<RpcDigitalIn>(); RPC::add_rpc_class<RpcDigitalOut>(); RPC::add_rpc_class<RpcPwmOut>();

RpcPwmOut PWM1(p21,"PWM1"); RpcAnalogIn pot(p19, "pot"); RpcDigitalOut rpc_led(LED1, "led");

receive commands, and send back the responses char buf[256], outbuf[256]; while(1) { pc.gets(buf, 256); Call the static call method on the RPC class RPC::call(buf, outbuf); pc.printf("%s\n", outbuf); } }


import mbed.* mymbed= SerialRPC('COM6', 9600); myled = DigitalOut(mymbed, LED1); pot = AnalogIn(mymbed, p19); PWM1 = PwmOut(mymbed,p21);

PWM1.period(0.001); duty= 0.02; i=0;



PWM1=duty; pause(0.05); duty=duty+0.02;

if (duty>1) duty=0.02; end


mymbed.delete; clear;

Comment on this question
Be the first to answer this question.

You need to log in to post a question