Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using Waveshare 1.54" ePaper Module. Using SPI peripheral:

  • CPU freq is 16Mhz
  • SPI Prescaler DIV by 8
  • MSB FIRST
  • CPOL=0, CPHA=1

The Display does not response but it respond with TI CC1310 properly. The problem with SPI is after transmitting byte it does not go to ideal high state.

I have checked with logic analyser. enter image description here enter image description here

The SPI is initialised thus:

/****************** Initializing The SPI Peripheral ******************/

void SPI_setup(void)
{
    CLK_PeripheralClockConfig(CLK_PERIPHERAL_SPI, ENABLE);  //Enable SPI Peripheral Clock
    //Set the MOSI, MISO and SCk at high Level.
    //GPIO_ExternalPullUpConfig(GPIOC, (GPIO_Pin_TypeDef)(GPIO_PIN_6),ENABLE);
    SPI_DeInit();
    SPI_Init(SPI_FIRSTBIT_MSB,                    //Send MSB First
             SPI_BAUDRATEPRESCALER_8,             //Fosc/16 = 1MHz
             SPI_MODE_MASTER,
             SPI_CLOCKPOLARITY_LOW,               //IDEAL Clock Polarity is LOW
             SPI_CLOCKPHASE_2EDGE,                //The first clock transition is the first data capture edge
             SPI_DATADIRECTION_2LINES_FULLDUPLEX, //Only TX is Enable 
             SPI_NSS_SOFT,
             0x00);
    SPI_Cmd(ENABLE);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
333 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is pretty much the same problem you had at Issue in interfacing SPI e-ink display with PIC 18F46K22 only on a different processor. Worth noting that CPHA on STM8 has the opposite sense to CPE on PIC18 which may be the cause of your error. That is to say that CPHA=1 on the STM8 has the same effect as CKE=0 on the PIC18. You really have to look at the timing diagrams for each part carefully.

From https://www.waveshare.com/wiki/1.54inch_e-Paper_Module: enter image description here

Compare with the STM8 reference manual: enter image description here

Clearly you need one of:

  • CPHA=1 / CPOL=1 (SPI_CLOCKPOLARITY_HIGH / SPI_CLOCKPHASE_2EDGE) or
  • CPHA=0 / CPOL=0 (SPI_CLOCKPOLARITY_LOW / SPI_CLOCKPHASE_1EDGE)

If it is the SCLK that you want to be normally-high, then you need the first option - although I fail to see why that is "ideal", the Waveshare diagram clearly indicates that either is acceptable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...