AnsweredAssumed Answered

Problems with SPI0 MOSI on a K64F

Question asked by Francesco Adamo on Aug 13, 2015
Latest reply on Sep 5, 2015 by Hui_Ma

Hi all,


I am facing a strange problem on a K64F interfaced to an SSD1306-based 128 x 64 OLED Display (following images); I use the FRDM-K64F and a FRDM-KL25Z with the MBED platform.



20150813_171453 (2).jpg


When I use the OLED display on the SPI port of the FRDM-KL25Z it works properly; when I use the same display or a twin one on the SPI0 port of the FRDM-K64F with the same code, all signals are correct except the MOSI one which is connected to the DIN line of the display: on the FRDM-K64F it appears greatly attenuated (almost with a factor of 10:1) or distorted with the shorter bits greatly attenuated and the display doesn't work at all.


I've tried also to use a different code on the FRDM-K64F sending the result of a 16-bit incrementing counter on the MOSI line and the result is the same: the signal is greatly attenuated until the MOSI line is connected to the DIN line of the display:




if I disconnect the MOSI signal from the display, it returns normal:


If I recompile and load the same code on the FRDM-KL25Z, the MOSI signal is always perfect!


NOTE: on both the previous pics the top waveform is the CS signal (used as the trigger) and the bottom signal is the MOSI one.


Here is the simple code I use to generate the previous signals:



#include "mbed.h"


#ifdef TARGET_K64F

#define SPI_SCK     PTD1

#define SPI_MOSI    PTD2

#define SPI_MISO    PTD3

#define SPI_CS      PTD0

#define I2C_SDA     PTE25

#define I2C_SCL     PTE24

#define displayDC   PTC4

#define displayRST  PTC3

#elif defined(TARGET_KL25Z)

#define SPI_SCK     PTD1

#define SPI_MOSI    PTD2

#define SPI_MISO    PTD3

#define SPI_CS      PTD0

#define I2C_SDA     PTE0

#define I2C_SCL     PTE1

#define displayDC   PTD5

#define displayRST  PTA13



DigitalOut myled(LED_GREEN);

DigitalOut spi_cs(SPI_CS);





int main() {

    uint16_t k = 0;

    spi_cs = 1;




    while(1)  {

        myled = !myled;

        spi_cs = 0;

        spi.write((k & 0xff00) >> 8);

        spi.write(k & 0xff);

        spi_cs = 1;






From the schematic of the FRDM-K64F it seems that the MOSI line of the SPI0 peripheral (PD2) is connected directly to the Arduino-like header whitout any series resistor and the same is on the FRDM-KL25Z; no other onboard peripherals are connected to these lines on both board.


Also, from the datasheet of the SSD1306, I read that the DIN signal is a normal digital input signal; no explicit note is reported about its input impedance.


For this reasons I am unable to find the cause of the MOSI attenuation on the K64F.


Is there anyone else that has tried to interface this kind of displays to the FRDM-K64F? If yes any hint will be appreciated!