USBSerial & DigitalIn/Out

11 Nov 2014

Hi all,

I have had this issue for some time and would appreciate someone to explain what the route of the problem could be.

I have a platform based on LPC11u24 running USBSerial library. My PC is able to recognise the COM port and successfully communicate with device however when I define several (let say 20 I/O pins - the aim is to use all unused I/O pins both IN and OUT) DigitalOut or BusOut pins within the code the USB COM port stops working.

Clearly, I/O pins that I am using are not used at all and therefore don't understand how is it possible that they cause the serial port from running successfully? The code looks like this:

example issue code

#include "mbed.h"
#include "USBSerial.h"

USBSerial serial;

//interestingly the software works with either myInputs or myOutpus defined
//but not when both are defined together
//it suggests that it is not related to a specific pin but something else
BusIn myInputs  (p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18);
BusOut myOutputs(p21,p22,p23,p24,p25,p29,p30,p34,p35,p36,p27,p28);/
int i=0;
    
int main(){ 
    //Changing to PullUp has no effect
    myInputs.mode(PullDown);          
    while(1){ 
        wait(1);
        serial.printf("Value %d\r\n",i);
        i++;
    }
}

Can anyone suggest why USBSerial won't work with this many digital pins?

Many thanks

Milan

15 Nov 2014

The serial class must rather be instantiated like

RawSerial   serial (SERIAL_TX, SERIAL_RX);
or 
Serial serial (SERIAL_TX, SERIAL_RX);

Try it

15 Nov 2014

USBSerial is a Serial connection over the MCUs own USB port. On your STM boards they are kinda hidden (although at least the F401 has the capability), but for example the Freescale boards have a seperate USB connector for those, and the original mbeds have the pins specifically labelled.

17 Nov 2014

USB connector is connected to the MCUs own USB port (LPC11u24) which is not a problem in this case. The problem is that it stops working when too many I/O pins have been defined - similarly to the code in the first post. Otherwise it works fine. What could be causing the USBSerial to hang? - is it something related to fan out? - perhaps something like tx shouldn't be defined as digitalIn? - ISR issue? - any suggestion?

26 Nov 2014

Hi,

I have tested mbed LPC11U24 platform with your test case, but could not reproduce the issue you reported.

Quote:

I have a platform based on LPC11u24 running USBSerial library.

Is your device LPC11U24/301 or 401? Your pinout are identical as mbed NXP LPC11U24 platform? e.g. p5 connect to P0_9?

05 Apr 2016

Hello!

Sorry bringing old threads up, but I'm having the same issue Milan had.

I'm using the KL25 Freedom Board, and tried to use USBSerial along with some IO's.

USBSerial alone works as expected, but when I add some IO's the board hangs, apparently before entering main, because the outputs are set to the default value (0, on object creation) and not to the ones I've set rigth on start of main.

Both mbed and USBDevice libs are updated.

I know I can use an USB to serial adapter, but it looks odd having the (fast) USB peripheral on MCU and using an external one...

Thanks!