2013-01-24 03:14 AM
Hello,
I try to get a ssb1322 oled display working with a stm32f4 board. The display is NHD-2.8-25664UCY2 from new heaven. The recurrent problem with this display is power, so I power it with an atx 3.3v. I also use freertos, but it just blink a led on port C. For delay, I use timer5. I use last ST lib for hardware spi. With multimeter, all lines seems to ok. I receive an oscilloscope tomorow to check that. Before I want to verify my spi init and using, this is the init (I use different port for SCK and MOSI) :void prvSPI1_Config()
{
GPIO_InitTypeDef GPIO_InitStructure;
//NVIC_InitTypeDef NVIC_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
/* Peripheral Clock Enable -------------------------------------------------*/
/* Enable the SPI clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
/* Enable GPIO clocks */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB, ENABLE);
////CS (portA, pin 4) et DC (portA, pin 6)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
//GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
//GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
////RESET (portB, pin 6)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//This is SSB1322 reset
GPIO_SetBits(GPIOB, GPIO_Pin_7);
OLED_Delay(300);
////SCK (portA pin 5)
GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1);
////MOSI (portB, pin 5)
GPIO_PinAFConfig(GPIOB, GPIO_PinSource5, GPIO_AF_SPI1);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
//GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
/* SPI SCK pin configuration (portA, pin 5) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* SPI MOSI pin configuration (portB, pin 5)*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* SPI configuration -------------------------------------------------------*/
SPI_I2S_DeInit(SPI1);
//SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32; //72/16 = 4.5 Mhz
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_Cmd(SPI1, ENABLE);
}
And this send functions :
u8 SPI_OLED_SendByte(u8 byte)
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
// Send byte through the SPI1 peripheral
SPI_I2S_SendData(SPI1, byte);
}
void oled_Command_25664(unsigned char Data)
{
////CS Low (portA pin 4)
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
/////DC Low (portA pin 6)
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
SPI_OLED_SendByte(Data);
////CS High (portA pin 4)
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
GPIO_SetBits(GPIOA, GPIO_Pin_4);
}
void oled_Data_25664(unsigned char Data)
{
////CS Low (portA pin 4)
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
/////DC High (portA pin 6)
GPIO_SetBits(GPIOA, GPIO_Pin_6);
SPI_OLED_SendByte(Data);
////CS High (portA pin 4)
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
GPIO_SetBits(GPIOA, GPIO_Pin_4);
}
Many help ? I begin with stm32, be indulgent ^^
2013-01-25 12:52 PM
I am glad I don't need to explain to you that observing several MHz signals with a 0.2s timebase is, ehm inadequate... :)
There's no need to run the SPI at full speed - run it at around say 100kHz and you can comfortably observe the waveforms with the scope you have at hand. But if you are confident that you did not messed up the signals, then I'd say chances are high that the problem is one level up. JW2013-01-27 03:33 AM
Don't be glad, I am not an electronician. I have not used an oscilloscope since school, 15yr ago ^^
I have set the clock to 281khz for testing. I do many test, many different timing, I hope the rest of my project will be less hazardous than oled display :) I work on it since 8 days now, and I have nothing more than black screen. I give up !2013-01-28 01:44 AM
It works ! But only in software SPI for instance.
I don't know the original probleme, may be several things, I do lot of modifications since my last software SPI test. As I say, I am not an electronician, but I think I have a synchronisation probleme between MOSI and SCK with hardware SPI, they don't seem to pulse at same frequency ! Is it possible ? Now, I have a working init sequence, fix this will be easier, I hope :)