cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F1 and ILI9341

kalinic3
Associate II
Posted on December 26, 2015 at 20:50

Hello,

I'm quite new to the ARM development and hope that you can help me.

I have a ILI9341 LCD without touch and wanted to display something 🙂

I got the library for an STM32F4 from this site and tried to rewrite it for use with my STM32F103RB.

http://mikrocontroller.bplaced.net/wordpress/?page_id=3071

Unfortuantely not even the SCK is working (measured with scope). There is no clock signal.

Does anybody has a working library for the ILI9431 LCD and the STM32F1?

Thank you very much in advance!

Greets electricar
7 REPLIES 7
Posted on December 27, 2015 at 00:22

Ok, in order to solve these kind of pins-don't-work issues, it would be helpful if you describe the pins you are using here, and show the GPIO and SPI configuration code you are currently using.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kalinic3
Associate II
Posted on December 27, 2015 at 14:20

Hello clive,

Thank you for your answer!

I'll try to post all relevant things. I'll attach also the whole project folder if there are further questions.

This is my rewritten code. I can also post the original code, but it's also in the attached zip file.

// SPI-Clock enable
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); 
// Clock Enable der Pins
RCC_AHBPeriphClockCmd(SPI2DEV.SCK.CLK, ENABLE);
RCC_AHBPeriphClockCmd(SPI2DEV.MOSI.CLK, ENABLE);
RCC_AHBPeriphClockCmd(SPI2DEV.MISO.CLK, ENABLE);
// SPI Alternative-Funktions mit den IO-Pins verbinden
//------------- Do I Have to do remapping here? This is the original code ------
//GPIO_PinAFConfig(SPI2DEV.SCK.PORT, SPI2DEV.SCK.SOURCE, GPIO_AF_SPI2);
//GPIO_PinAFConfig(SPI2DEV.MOSI.PORT, SPI2DEV.MOSI.SOURCE, GPIO_AF_SPI2);
//GPIO_PinAFConfig(SPI2DEV.MISO.PORT, SPI2DEV.MISO.SOURCE, GPIO_AF_SPI2);

//--------------------------------------------------------------------------

// SPI als Alternative-Funktion Push Pull
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
// SCK-Pin
GPIO_InitStructure.GPIO_Pin = SPI2DEV.SCK.PIN;
GPIO_Init(SPI2DEV.SCK.PORT, &GPIO_InitStructure);
// MOSI-Pin
GPIO_InitStructure.GPIO_Pin = SPI2DEV.MOSI.PIN;
GPIO_Init(SPI2DEV.MOSI.PORT, &GPIO_InitStructure);
// MISO-Pin
GPIO_InitStructure.GPIO_Pin = SPI2DEV.MISO.PIN;
GPIO_Init(SPI2DEV.MISO.PORT, &GPIO_InitStructure);
// SPI-Konfiguration
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
if(mode==SPI_MODE_0) {
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
}else if(mode==SPI_MODE_1) {
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
}else if(mode==SPI_MODE_2) {
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
}else {
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
}
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI2_VORTEILER;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2, &SPI_InitStructure); 
// SPI enable
SPI_Cmd(SPI2, ENABLE);

Greets electricar

________________

Attachments :

LCD.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0o5&d=%2Fa%2F0X0000000bfF%2Femrrw8V5jQ.h5t5t8CYF6tGHVQHQCCctmFLHE_yaIiY&asPdf=false
Posted on December 27, 2015 at 14:44

This is the problem with burying stuff in defines/structures

RCC_AHBPeriphClockCmd(SPI2DEV.SCK.CLK, ENABLE);

// The GPIO clocks are ON APB2 not AHB
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kalinic3
Associate II
Posted on December 27, 2015 at 15:04

Hello clive,

thak you for your answer. Unfortunately nothing changed. I actually don't know how easy/hard it is to rewrite a library from F4 to F1. Perhaps something went wrong during rewriting it.

Do I have to do remapping of the SPI2 pins on the STM32F103RB?

Posted on December 27, 2015 at 15:27

Do I have to do remapping of the SPI2 pins on the STM32F103RB?

The

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00161566.pdf

, the controlling reference here, suggests not. I did initially ask what pins you were using.

You might want to review other SPI examples provided in the SPL projects directories.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kalinic3
Associate II
Posted on December 27, 2015 at 15:56

Oh I forgot this:

SPI2_DEV_t SPI2DEV = {
// PORT , PIN , Clock , Source 
{GPIOB,GPIO_Pin_13,RCC_APB2Periph_GPIOB,GPIO_PinSource13}, // SCK an PB13
{GPIOB,GPIO_Pin_15,RCC_APB2Periph_GPIOB,GPIO_PinSource15}, // MOSI an PB15
{GPIOB,GPIO_Pin_14,RCC_APB2Periph_GPIOB,GPIO_PinSource14}, // MISO an PB14
//Original library
//{GPIOB,GPIO_Pin_13,RCC_AHB1Periph_GPIOB,GPIO_PinSource13}, // SCK an PB13
//{GPIOB,GPIO_Pin_15,RCC_AHB1Periph_GPIOB,GPIO_PinSource15}, // MOSI an PB15
//{GPIOB,GPIO_Pin_14,RCC_AHB1Periph_GPIOB,GPIO_PinSource14}, // MISO an PB14
};

L C
Associate II
Posted on April 24, 2017 at 02:44

Any news/update?