2013-12-19 06:03 AM
Hello everybody,
I communicate with a popular screen, the DOGM128 (ST7565RLCD Controller) with my STM32F4 uC. Sometimes, when I power on my board, the screen have troubles to be initialized (it remains white, whatever I do). I think it's due to the SPI speed, that I can't estimate. The max SPI clock speed of the screen controller is 20MHz. This is my SPI screen init :RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
// CLOCK and MOSI Pins declaration
GPIO_InitStructure.GPIO_Pin = PIN_SCL|PIN_SI;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
// CS pin
GPIO_InitStructure.GPIO_Pin = PIN_CS|PIN_A0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
// SI & SCL = Alternate Functions
GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_SPI2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_SPI2);
SPI_InitTypeDef SPI_InitStruct;
SPI_I2S_DeInit(SPI2);
SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStruct.SPI_CRCPolynomial = 7;
SPI_Init(SPI2, &SPI_InitStruct);
SPI_Cmd(SPI2, ENABLE);
With SPI_BaudRatePrescaler_2 : The screen works almost everytime
With SPI_BaudRatePrescaler_4 :The screen works half the time
With SPI_BaudRatePrescaler_8 :
The screen never works
So how can I increase the SPI speed, in order to try to solve my problem ?2013-12-28 12:56 AM
OK the Main clock is configured for 168MHz
APB1 and APB2 can be changed with RCC_CFGR fields PPRE1 and PPRE2 File system_stm32f4xx.c SetSysclock procedure contain this codeRCC->CFGR |= RCC_CFGR_HPRE_DIV1;
#if defined (STM32F40_41xxx) || defined (STM32F427_437xx) || defined (STM32F429_439xx)
/* PCLK2 = HCLK / 2*/
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
/* PCLK1 = HCLK / 4*/
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx */
#if defined (STM32F401xx)
/* PCLK2 = HCLK / 2*/
RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
/* PCLK1 = HCLK / 4*/
RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
#endif /* STM32F401xx */
I don't know
what device
you
are using
for
the
F407
that I use
: AHB max 168MHz --> HPRE = 0 (RCC_CFGR_HPRE_DIV1) use PPL frequency output = 168MHz APB1 max 42MHz --> PPRE1 = 101 (RCC_CFGR_PPRE2_DIV4) datasheet max frequency APB2 max 84MHz --> PPRE2 = 100 (RCC_CFGR_PPRE2_DIV2) datasheet max freqeuncy SPI2 prescaler divide APB1 clockFor your problem
try to
fix
the clock line
with
a
resistor
pullup
/
dn
(sorry my mistake use a pullup on CS linebut you probably
already do
)at startup
until the
micro
does not configure
the
SPI
line
the clock line is is held to fixed value2014-02-12 08:10 AM
Sorry for the delay I was not here during a long long time....
''For your problem
try to
fix
the clock line
with
a
resistor
pullup
/
dn
(sorry my mistake use a pullup on CS linebut you probably
already do
)'' > My CS line is pulled with the integrated pullup. But it change nothing to my problem...''at startup
until the
micro
does not configure
the
SPI
line
the clock line is is held to fixed value''> I don't understand... Should I fix myself the clock line to a fixed value at the startup ? For example to the high level ?Thanks !2014-02-12 11:15 PM
I reread the thread
if you're sure that the CS is always high during display startup the problem isn't a spurious switching of the SPI at startup Another assumption :you're too fast and you start the configuration of the display before it has finished the powerup procedure. Adding a delay before init LCD may solve. I have a doubt: The first post contain code init for SPI2 but after you say that you have added: RCC_APB1PeriphClockCmd (RCC_APB1Periph_SPI2, ENABLE), without this call the SPI2 can't work Are you sure use SPI2 ? You can check the SPI lines with oscilloscope ?2014-03-12 04:09 AM
hello,
I think I tried everything to solve my problem but the init error still occurs. I try to init my screen after a long delay from the SPI2 init (yes I'm sure to use the SP2 :) ) but no change.My board is USB powered, with a mechanical switch to ON/OFF the 5V power. When I plug the USB connector with the switch ON the problem never happend. But when I use the ON/OFF switch, sometime (like 1 time on 20) there is a perpetual black screen. Strange isn't it ?2014-03-12 07:25 AM
Strange isn't it ?
Stranger perhaps that your description of the problem is still anecdotal, rather than having some clear analysis supported by timings observed on a scope or logic analyser, and contrasting the behaviour between working and failing conditions.2014-03-12 08:21 AM
EADOG LCD controller ST7565R Ver 1.5 page 40:
When the power is turned on, the IC internal state becomesunstable, and it is necessary to initialize it using the /RES
terminal. After the initialization, each input terminal should
be controlled normally. The problem can be solved only using RST pin (I have a lot of board with same display that working without problem)
2014-03-12 10:15 AM
Yes I think it's the only solution... it's a pity that the screen chip don't manage that, PCB designers have to put another track just for reset the screen at startup...