0
votes

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);
}
1
What do those "magic" functions do? - 0___________
I removed the zoom'ed out trace previously as irrelevant, but now it is apparent that it is the busy signal that concerns you (even though your SPI mode was incorrect), I have added it back in. I would have assumed that given the SPI mode correction however the BUSY would have become valid. Probably better to start a new question with the correct SPI mode if it is still not working since you then clearly have other problems. - Clifford
I note that the Waveshare WiKi states "BUSY Busy state output pin (Low for busy)" while the User Manual says "BUSY :Busy(High active". Good luck with that! This inconsistency is noted at github.com/mcauser/micropython-waveshare-epaper/issues/2. The example code provided agreed with the user manual - i.e. BUSY = HIGH. Note the pin state refers to the busy state of the display, not the SPI interface. Have you configured the GPIO correctly? I appreciate that I deleted that code as irrelevant! - Clifford
... Looking at the original code BUSY was configured GPIO_MODE_IN_FL_NO_IT. - Clifford
The documentatuion fo rteh part is terrible, only showing how to use it with libraries - where are you getting your information on how to drive this from? What makes you think that the BUSY state should change when you send that sequence? The documentation makes no mention of the purpose to behaviour of that pin. What are you expecting to happen, what actually happens? - Clifford

1 Answers

0
votes

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.