Search Notebooks
BusOut, PortOut, DigitalOut speedup

Notes on speeding up DigitalOut, BusOut and the PortOut concept

BusOut, digitalOut, PortOut, slow, Speed

Page owner: user Simon Ford

Created 20 Mar 2010.
Last updated 20 Mar 2010

BusOut, PortOut, DigitalOut speedup

Page last updated 20 Mar 2010, by   user Simon Ford   tag BusOut, digitalOut, PortOut, slow, Speed | 3 replies      

After some chatting in the forums about slow I/O, I thought it'd be worth capturing...

Here is the test code:

#include "mbed.h"
#include "PortOut.h"
#include "DigitalOut2.h"

BusOut bus(P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31);
PortOut port(PORT1, 0xFF000000);
DigitalOut out(LED1);
DigitalOut2 out2(LED2);

Timer t;

int main() {

    t.start();
    for(int i=0; i<1000000; i++) {
        bus = 0;
        bus = 0xFF;
    }
    printf("BusOut  = %8d kHz\n",(int)( 1000.0 / t));

    t.reset();
    for(int i=0; i<1000000; i++) {
        port = 0;
        port = 0xFF000000;
    }
    printf("PortOut = %8d kHz\n", (int)(1000.0 / t));
    
    t.reset();
    for(int i=0; i<1000000; i++) {
        out = 0;
        out = 1;
    }
    printf("DigitalOut = %8d kHz\n", (int)(1000.0 / t));

    t.reset();
    for(int i=0; i<1000000; i++) {
        out2 = 0;
        out2 = 1;
    }
    printf("DigitalOut2 = %8d kHz\n", (int)(1000.0 / t));
}

And here are the results based on an 8-bit BusOut, an initial PortOut and optimised DigitalOut design, maintaining the same API.

BusOut       =  132 kHz   (8-bit)
PortOut      = 5052 kHz   (approx x38 speedup)

DigitalOut   = 1246 kHz
DigitalOutv2 = 7384 kHz   (approx 6x speedup)

These suggest a PortOut gives good results even with a nice clean API, and the DigitalOut can be sped up too. These seem like good potential additions to the API.

As BusOut is constructed from DigitalOut, that would naturally speed up too.


3 comments

23 Mar 2010

Hi

I tried to test the code and have an error:

"Cannot open source input file "PortOut.h": No such file or directory (E5)" in file "/SpeedUpDigitalOut/main.cpp"

It's obvious that portout.h  is missing

Where can i find that file? A search did not work. Also is good to have a link to all different xxx.h   files. i keep searching for them for any project.

Sorry for asking but i m new to this and keep trying to navigate and test different codes.

Thanks

Thanos

23 Mar 2010

Hi Thanos,

These are just my own notes at the moment as i'm working on this; the source isn't published yet as I haven't quite finished them, but I am further with it and is looking good. If all looks good, it may even get in to the next library release.

Thanks for the interest!

Simon

28 Apr 2010

Hi simon,

I am new to mbed and tried sample programs.I want to test ADC with PWM can you suggest me some sample codes.....

 

Thanks in advance...

Regards

Sathishnarayan

Please log in to post a comment.