AnsweredAssumed Answered

SPI and SSB1322

Question asked by Sam on Jan 24, 2013
Latest reply on Jan 28, 2013 by Sam
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 ^^

Outcomes