Interfacing SSD1306 with SPI bus on KL43Z

Showing results for 
Search instead for 
Did you mean: 

Interfacing SSD1306 with SPI bus on KL43Z

Contributor III

Hello freescale community!

I have a KL43Z board. So far I have done some hello world (and similar) programs with no problems.

Now I want to connect my SSD1306 LCD to Kinetis board. After figuring out the pinout for this connection (using SPI1 from the Arduino-compatible connector), currently I am completely stuck.

I was looking for any tutorial that will show me how to configure (in Processor Expert(?)) and program SPI bus, so that I can display anything on the mentioned LCD. Should I use Processor Expert or write it from scratch?

To make things easier - I downloaded the popular u8glib library, which I know from Arduino. Unfortunately I have no idea on how to adapt it for the MCU present on Kinetis board. Has anybody ported that library to any Kinetis board? The LPC Cortex-M0 configuration which is the only one available in it - is completely different from this board and gives dozens of errors in KDS.

Thank you in advance for any advice!


0 Kudos
3 Replies

Contributor III

Hi Peter,

I've not worked with the SSD1309, but I did manage to get a project working with the SSD1289, and also the ILI9341.  Here's a few suggestions:

1. If you are using SPI to communicate, I HIGHLY recommend using the DMA controller to manage your reads/writes as I think the fastest you can communicate to the TFT controller using SPI is around 10 MHz clock rate.

2. The other problem I ran into was not having enough RAM to hold an entire frame in memory with a 320x240 at 16 bit color depth since the L series Kinetis only have max of 32 kB.  I ended up using as much RAM as I could to hold up to 1/6th or 1/5th of a frame in memory and had to manage reloading the DMA transfer for larger images or screen updates.  It might be that for a large bitmap you just use the DMA to transfer it to the TFT controller directly from flash.

3.  You definitely need to get your graphics primitive functions working and then you can build on top of that.  I think I had the best inspiration from the Processor Expert graphic display components that you can find on (a GREAT site for lots of helpful info BTW, I owe a lot of what I've learned about Kinetis MCU's to Erich Styger).  I will mention that some of the graphics primitives functions there need to be optimized a little bit to work with the KL family due to limited RAM and speed.  Opening a window to draw a single pixel, for instance, just doesn't work from a performance standpoint, so you may need to be a little creative.

Hope this helps!


0 Kudos

Senior Contributor III

I have indeed set up DMA to SSD3105 (embedded on my 128x64 OLED display cable).  I use two chip-selects, one of which is D/!C, and assert one or both 'as necessary'.  Those basics are in my post in:

I just let my 'timer tick' enable the block-dump of the entire command- and data-array into the chip every 20ms, and let the DMA do all the work.  This array is set up as 32bits, but I only use the 'bottom 8' of each such long-word for screen data.  The upper half is SPI-controls, and since the SSD is a 'byte' device each transfer is 8 bits.

I also have line-draw and bit-blt graphics routines to fill this monochrome bitmap using highly-efficient bit-banding operations as on K processors -- email me and I will supply.

But now I see you call out a KL processor, so my 'K' code is not very helpful in any direct way -- both DMA and SPI hardware are significantly different.  And instead of bit-banding there is the BME - that would require some changes  to my drawing code too...

0 Kudos

NXP Employee
NXP Employee

Hi Piotr,

Unfortunately we don't have a library to work with the SSD1306 LCD, but you can find several SPI driver examples in Kinetis SDK that can help you create your LCD driver:


Kinetis SDK can be downloaded from the link below, choose the Kinetis SDK 1.2 Mainline which is the newest version and supports the KL43Z MCUs:

Software Development Kit for Kinetis MCUs|Freescale

You can also use Processor Expert with Kinetis SDK, information about the fsl_spi component properties, methods and events can be found on the help of the component:


Hope it helps!

Best Regards,

Carlos Mendoza

Technical Support Engineer


Note: If this post answers your question, please click the Correct Answer button. Thank you!


0 Kudos