Mbed as FTDI cable?

06 Mar 2010

Can I use the mbed instead of a FTDI cable (I don't have one and don't want to get one if unnecessary)?

Is it as simple as connecting up the TX / RX of the device I am trying to program (an LS20031 GPS) to relevant mbed pins then writing code for the mbed to pass everything through via USB?  I would then use something like minigps in the same way as if I had an FTDI cable.

eg:

 

#include "mbed.h"


Serial gps(p9,p10);

Serial pc(USBTX,USBRX);


int main() {

    
    while(1) {
    
      
      if ( gps.readable()) {
        
        pc.putc(gps.getc());
      }
 
      if (pc.readable()) {
      
        gps.putc(pc.getc());
      
      }
    
   
    }

}

 

 

06 Mar 2010

Yup there's a how to use the mbed as an USB->TTL serial interface for programming.

I would suggest you use the serial interrupt to do the translation.

You can always hack a Nokia CA-42 cable if you're stuck. (They're about $3 or £2)

06 Mar 2010

Thanks Andrew.  One issue I've come across is that the MBED usb interface is not accessible to my windows virtual machine (I'm using virtualbox on a mac).  It shows up but is greyed out.  Any ideas?  I've been able to connect the sparkfun xbee usb explorer without problems using this method.

07 Mar 2010

Sorry, don't use a Mac so can't help on that front unfortunately, maybe one of the other Mac users could offer some advice?

07 Mar 2010 . Edited: 07 Mar 2010

edited to remove duplicate

07 Mar 2010

No worries, thanks for your help.  I've got something to try - I'll post back here for other people's reference if it works but if there are any mac Virtualbox users out there in the meantime...

10 Mar 2010

Update: Got mbed working on Virtualbox by 1. rolling back to version 3.1.2 (from 3.1.4). 2. making sure to plug the mbed after the virtual machine had fully loaded 3. installing the windows drivers http://mbed.org/handbook/WindowsSerialConfiguration

 

 

04 Feb 2011

FWIW, I was able to kludge together some code so I could get MiniGPS to configure my LS20031. Interrupt driven would've been much better, but I was impatient. :) I didn't make the code public because it's so bad. :)

05 Feb 2011

Can you please share Michael?? I'm short an MBED at the moment (in Aus while I'm now in London) but have just got my GPS module back and want to try testing it again.

05 Feb 2011

Ok... if it'll help. This was just enough to allow me to config the LS20031. I think a few times I would have to click a MiniGPS button to get the config to work. So, the data from GPS -> PC is polling. The PC -> GPS is interrupt driven. I had a bad GPS and was in a hurry to simply prove that I could configure *anything* on the GPS... so the code below didn't need to be perfect, just barely useful. :)

#include "mbed.h"

// Program to use the  mbed as a serial bridge
//
Serial pc(USBTX, USBRX); // tx, rx
Serial dev(p9, p10); // tx, rx

void send() {
    while (pc.readable()) {
        dev.putc(pc.getc());
    }
}

void recv() {
    pc.putc(dev.getc());
}

int main() {
    char c;
    
    // PC serial     
    pc.baud(115200);
    pc.attach(send, Serial::RxIrq);
    
    // Device serial 
    dev.baud(9600);   // LS20031 57600 

    //dev.printf("$PMTK314,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,5*2D\r\n");
    //dev.printf("$PMTK103*30\r\n");

    while(1) {
    
        c = dev.getc();
        pc.putc(c);

    }

}