LonelyWolf / stm32

STM32 stuff
The Unlicense
949 stars 496 forks source link

ls027b7dh01 blank display #24

Closed scs102 closed 4 years ago

scs102 commented 4 years ago

When ls027b7dh01 was tested with an LS044Q7DH01 display, the display was blank, It worked when the SPI baud rate was reduced from 16MHz (2MHz fSCLK) to 1.6MHz (1MHz fSCLK). The typical fSCLK frequency is 1MHz and maximum is 2MHz from the LS044Q7DH01 datasheet.

Also the SPI configuration in main.c is hardcoded to use SPI2, rather than use the configuration from the header file.

#if (SPI1_USE)
    SPI1_HandleInit();
#endif
#if (SPI2_USE)
    SPI2_HandleInit();
#endif
#if (SPI3_USE)
    SPI3_HandleInit();
#endif
    SPI_Init(&SMLCD_SPI_PORT, SPI_CLK_PL_E1, SPI_DIR_TX);
    SPI_SetDataWidth(&SMLCD_SPI_PORT, SPI_DW_8BIT);
    SPI_SetRXFIFOThreshold(&SMLCD_SPI_PORT, SPI_RXFIFO_THQ);
    //SPI_SetBaudrate(&hSPI2, Clock_SPICalcDivider(&hSPI2, 16000000));
    SPI_SetBaudrate(&SMLCD_SPI_PORT, Clock_SPICalcDivider(&hSPI2,     16000000/10));
    SPI_Enable(&SMLCD_SPI_PORT);
LonelyWolf commented 4 years ago

Unfortunately, I did not had a chance to work with LS044Q7DH01 (it's damn expensive). I worked with LS027B7DH01 whose datasheet says about the same SCLK signal characteristics. In my case I've played with frequencies and display worked at SCLK frequencies up to 15 MHz without any problems. At higher frequencies the noise on the image appeared after the transitions from black to white and vice versa. So as to to the choice of SCLK frequency: the manufacturer guarantees work at up to 2 MHz... but if the display can work at higher ones, why not? Why the LS044Q7DH01 was blank in your case? Can't say for sure... Maybe it more strict to the SCLK frequency... Maybe the matter in the quality of the lines between the MCU and the display...

As for the Clock_SPICalcDivider() function: it picks the SPI baud divider so as to get the clock frequency as close as possible to the specified value. In this example (if you use it as is, i.e. Clock_SPICalcDivider(16000000) and the MCU working at 80MHz) the SPI frequency will be 10MHz.

Finally, as for the hardcoded SPI initialization: I am a lazy ass and have not much time for playing with this. Thus I didn't want the hassle and committed a minimally working example. Sorry :)

PS: not so long ago I got a couple of the LS018B7DH02. When I will have some free time and the mood for this, I want to make an interface adapter (with very low power impulse generator) and try this library with those displays. It may come that I will manage to do more tidy and flexible example.

scs102 commented 4 years ago

Thanks. SCLK measured approximately 2MHz on logic analyser, but I didn't zoom in too much so it could have been just over the limit.