element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • 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
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs High Throughput SPI traffic part 2 - SPI with Buffers
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 20 May 2016 12:44 PM Date Created
  • Views 529 views
  • Likes 9 likes
  • Comments 2 comments
  • educational_boosterpack
  • lcd
  • spi
  • mibspi
  • serial
  • buffered spi
  • hercules
  • launchpad
Related
Recommended

High Throughput SPI traffic part 2 - SPI with Buffers

Jan Cumps
Jan Cumps
20 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

 

In this blog, I introduce the buffered SPI. I'm sending 64 16-bit values in one SPI call..

 

Our Unbuffered SPI Performance

 

Until now, I've sent data to the LCD pixel by pixel. I've optimised the drawing functions as much as I could.

I reduced the

  • number of SPI calls from 8 * 128 = 1024 per line to 7 + 128 = 135 per line,
  • number of bytes sent from 128 * 13 = 1664 per line to 11 + 128 * 2 = 267 bytes per line,
  • lined draw time from 2.6 ms to 376 µs.

That's as far as I can go with the pixel per pixel approach. There isn't much more gain to be eeked out of this design.

 

Buffered SPI: Offload Work to the SPI module

 

If I want to improve drawing speed, I'll have to switch to transmitting multiple pixels in one SPI call.

The Hercules microcontroller that I use supports this. Next to standard SPI, it has a multi-buffered SPI (MibSPI) mode.

I'll configure the MibSPI to take a buffer of 64 16-bit words. The MibSPI functions will take care that the SPI module accepts that buffer and pumps that to the LCD in one go.

I'll be able to send all pixels for a full line in 2 SPI calls instead if 128.

 

I can reuse a data format that I'm already using from the pixel-by-pixel format. The data doesn't change.

It's still 16-bit, 27.5 MBaud as before.

image

What I do change is the way that data is handed over to the SPI module. I configure MibSPI so that it preps and send 64 entities of data format 1 in one single shot.

 

image

 

In the firmware, I tell MibSPI where the address of the first 16-bit values is. It will then, all by by itself, send the 64 values from that address on to the slave, one shot.

 

void _writeData64(uint16_t *data) {
    gioSetBit(_portDataCommand, _pinDataCommand, 1);
    mibspiSetData(mibspiREG3, 2, &data[0]);
    mibspiTransfer(mibspiREG3, 2 );
    while(!(mibspiIsTransferComplete(mibspiREG3, 2))) {
    }
}

 

A full line takes me 2 calls:

 

void flashBitmapLine(bitmap_t *bmp, uint32_t line) {
    loadBitmapInDMABuffer(bmp, line);
    _writeData64(&TXDATA[0]);
    _writeData64(&TXDATA[63]);
}

 

The changes I had to make to the code are small. I get a decent payback though.

image

 

I still require 16 µS to get the LCD line initialised. The 2 64 16-bit buffers though, dropped from 360 µs to 97.2 µs.

 

  • number of SPI calls from 7 + 128 = 135 per line to 7 + 2 = 9 per line,
  • number of bytes sent stays 11 + 128 * 2 = 267 bytes per line. I've exhausted the possibilities to improve that already. We send exact the same data (with less SPI calls, and faster.
  • lined draw time from  376 µs unbuffered to 114 µs buffered.

 

image

Long live buffered SPI. It doesn't make my program more complex. But improves speed drastically.

This changes in the next blog where I bring DMA to the mix. That adds some complexity.

I'm starting my learning now: https://training.ti.com/hercules-tutorial-mibspi-and-dma-overview

 

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

  • balearicdynamics
    balearicdynamics over 7 years ago +3
    Another big piece of well explained methodology ! Thank for this series. Enrico
  • DAB
    DAB over 7 years ago +3
    Yes, a little reading and thinking can lead to greatly increased speed and simplification. I will see how much I remember about DMA when you start there. DAB
  • DAB
    DAB over 7 years ago

    Yes, a little reading and thinking can lead to greatly increased speed and simplification.

     

    I will see how much I remember about DMA when you start there.

     

    DAB

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago

    Another big piece of well explained methodology !

     

    Thank for this series. Enrico

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
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 © 2023 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube