element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs High Throughput SPI traffic part 1b - SPI without Buffers
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 17 May 2016 6:13 PM Date Created
  • Views 2336 views
  • Likes 9 likes
  • Comments 7 comments
  • educational_boosterpack
  • lcd
  • boosterpack
  • spi
  • mibspi
  • texas_instruments
  • microcontroller
  • hercules
  • launchpad
Related
Recommended

High Throughput SPI traffic part 1b - SPI without Buffers

Jan Cumps
Jan Cumps
17 May 2016

We know SPI as a 4*-wire protocol. But it doesn't have to be.

I'm checking high speed SPI data transfer with buffers, DMA and parallel data lines.

 

image

 

Let's analyse what the SPI cost is of my naive implementation, where I paint pixel by pixel.

 

SPI Traffic for a Single Pixel

 

Painting a single pixel on the LCD requires 8 SPI calls. In total we move 15 bytes.

The majority is spent on setting a draw window of 1 x 1 pixel. The paint command by itself just takes 2 bytes.

 

Code snippet

 

    _writeCommand(HX8353E_CASET);
    _writeData16(x0);
    _writeData16(x1);
    _writeCommand(HX8353E_RASET);
    _writeData16(y0);
    _writeData16(y1);
    _writeCommand(HX8353E_RAMWR);
    _writeData16(colour);

 

 

 

actionbytestotal
start point command1 byte1
coordinate x2 bytes3
coordinate y2 bytes5
end point command1 byte6
coordinate x2 bytes8
coordinate y2 bytes10
write data command1 byte11
write the pixel colour2 bytes13

 

The analyser trace looks like this:

image

And the protocol analyser tells us:

image

 

Almost 20 µS for a pixel. My SPI clock runs at 27.5 Mbits per second.

13 bytes per pixel is 1664 bytes for one line of 128 pixels.

2.6 ms per line (20µs x 128). 328 ms for the whole 128 x 128 bitmap.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

A Slightly Less Naive Approach

 

Let's try a first speed bump by setting the window to one line in stead of one pixel, and then push the data after that.

Unbuffered still. We are looping through the line and send a pixel at a time over SPI.

But we only send the positioning and windowing bytes (11 of the 13) only once per line.

A saving of 1397 bytes per single line.

 

Code snippet:

void setBitmapInOneThrow(bitmap_t *bmp) {
  uint32_t xx, yy;


    for (yy = 0; yy < bmp->height; yy++) {
        _setWindow(0, yy, bmp->width, yy );
      loadBitmapInDMABuffer(bmp, yy);
        for (xx = 0; xx < bmp->width; xx++) {
        _writeData16(TXDATA[xx]);
        }
    }
}

 

 

We still spend the same time for these activities as in the previous implementation.

image

16 µS to get the LCD screen initialises. For a whole line now.

 

Beaming the full line of data, 128 x 2 bytes, took us 360 µS

 

image

 

The total time to draw a line decreased from 2.6 ms per line to 376 µS.

 

In the next blog, we'll try to bring the 360 µS pixel data transmit further down by using buffered SPI.

 

The Series
0 - Buffers and Parallel Data Lines
1a - Buffers and DMA
1b - SPI without Buffers
2 - SPI with Buffers
3a - SPI with DMA
3b - SPI with DMA works
4a - SPI Master with DMA and Parallel Data Lines
Hercules microcontrollers, DMA and Memory Cache
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 9 years ago in reply to DAB +4
    Here's the test set-up: A Hercules RM46 LaunchPad. The RM46 is part of TI's Hercules family. This one is specialised in industrial and medical applications. Loads of safety features on that controller…
  • Jan Cumps
    Jan Cumps over 9 years ago +4
    Sneak preview: This isn't a full functioning implementation yet, but by tweaking some SPI registers in debug mode, I managed to push 128 16-bit values in one go: 82 µs for a full line. Compared to non…
  • Jan Cumps
    Jan Cumps over 9 years ago +4
    Issue resolved in less than an hour. It was pebkac. Datasheet says that we can have 128 values in our buffer. I was trying to send 128 at a time and that failed. The reason for this: I'm using 3 transfer…
Parents
  • DAB
    DAB over 9 years ago

    Nice blog.

     

    I like how you showed how to use some simple techniques to save time during the write cycle.

     

    Back in the early days, 1970's, we were always coming up with time saving techniques due to the very slow cycle time, >1 microsecond per instruction,  for the computers we had then.

     

    Doing complex graphis, just 100 by 100 bits took a lot of time to read from disk and send to the output buffers.

     

    We seldom ran at full resolution, 400 by 400, due to the time it took to display the image.

     

    So your experience with SPI brings back a lot of memories for me as we waited for the technology to improve.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 9 years ago in reply to DAB

    Here's the test set-up:

     

    A Hercules RM46 LaunchPad. The RM46 is part of TI's Hercules family. This one is specialised in industrial and medical applications.

    Loads of safety features on that controller, including 2 ARM Cortex cores in lockstep. Each processor instruction is executed on both cores, and then output is compared.

    All peripherals have redundant functionality - also for safe operation under harsh conditions. Memory consistency is checked at each instruction.

     

    A Educational BoosterPack MKII, with 128  128 full colour display.

    For this exercise, I'm moving loads of data via SPI to that display.

    The BoosterPack has been idle in my lab for months. It didn't work on the Hercules LaunchPad by default.

    It was only when I could lay my hands on a TM4C LaunchPad - where the display works - that I was able to understand its functionality, leading to my port of the display driver to Hercules.

    I have to admit that starting without a working implementation, just with the datasheets, is not my forte. I respect everyone who can.

     

    The Papilio Pro FPGA board that serves as my logic analyser and protocol decoder. In essence, this is just an FPGA running on its own, doing both the sampling and the communication with the GUI on my computer.

    The only other logic on the Papilio is some flash t store the configuration (although not essential for this application; I could load the config to the FPGA at runtime if I wanted) and a USB chip (affraid to name it, because shabaz would chime in).

     

    image

     

    A few humble parts. LaunchPad + BoosterPack less than $50 together. The Papilio around the same amount if I remember well.

    Endless joy and learning power.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 9 years ago in reply to Jan Cumps

    Nice post!! Also that analyzer has got me out of a few holes over the years : ) A nice design that "just works"..

    LOL @ ft*i. Thinking of creating a through-hole PCB  (open source of course) design for MCP2221, I've been using the

    stripboard prototype version for months now, reliable part from Microchip. Since it has a built-in ADC, that could be a value-add,

    e.g. use it for testing what the applied voltage is, since not all hobbyists initially have a multimeter.

    Open to ideas/suggestions though on any features you'd like to see in such a through-hole project, form factor, etc.

    Another option is to turn the spare GPIO pins into an MSP430 programmer. Kind of like a beginners swiss army knife.

    Just need to keep the parts count low.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • shabaz
    shabaz over 9 years ago in reply to Jan Cumps

    Nice post!! Also that analyzer has got me out of a few holes over the years : ) A nice design that "just works"..

    LOL @ ft*i. Thinking of creating a through-hole PCB  (open source of course) design for MCP2221, I've been using the

    stripboard prototype version for months now, reliable part from Microchip. Since it has a built-in ADC, that could be a value-add,

    e.g. use it for testing what the applied voltage is, since not all hobbyists initially have a multimeter.

    Open to ideas/suggestions though on any features you'd like to see in such a through-hole project, form factor, etc.

    Another option is to turn the spare GPIO pins into an MSP430 programmer. Kind of like a beginners swiss army knife.

    Just need to keep the parts count low.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube