Skip to main content
vik1970va
Associate II
November 16, 2018
Question

STM32F030F4 and SPI

  • November 16, 2018
  • 10 replies
  • 1575 views

..

This topic has been closed for replies.

10 replies

Tesla DeLorean
Guru
November 16, 2018

Try again with some content/description

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
vik1970va
vik1970vaAuthor
Associate II
November 16, 2018

After setting the bus IP in 1-line bidirectional data mode, the selected and Output enabled (transmit-only mode) DR register to which data is to be transmitted is in the "READ" state and it is impossible to write any data to it. I enclose part of the initialization code of the SPI bus. In this particular case, I connect the SPI screen and part of the pins intended for controlling the CS and RD. This code works on STM32F103C8B dv in several projects ...

vik1970va
vik1970vaAuthor
Associate II
November 16, 2018

void SPI1_Init(void)

{

RCC->APB2ENR |= RCC_APB2ENR_SPI1EN ; //çàïóñê òàêòèðîâàíèÿ SPI1

RCC->AHBENR |= RCC_AHBENR_GPIOAEN ; //çàïóñê òàêòèðîâàíèÿ �?îðò À

// RCC->APB2ENR |= RCC_APB2ENR_AFIOEN ; //çàïóñê òàêòèðîâàíèÿ àëüòåðíàòèâíûõ ôóíêöèé

//èíèöèàëèçàöèÿ ïèíîâ äëÿ SPI1

  GPIO_StructInit(&ports);

  ports.GPIO_Mode = GPIO_Mode_AF;

  ports.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_7;

  ports.GPIO_Speed = GPIO_Speed_10MHz;

  GPIO_Init(GPIOA, &ports);

//èíèöèàëèçàöèÿ îñòàüíûõ ïèíîâ

  GPIO_StructInit(&ports);

  ports.GPIO_Mode = GPIO_Mode_OUT;

  ports.GPIO_Pin = LCD_CONT;

  ports.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(LCD_CTP, &ports);

  

 GPIO_StructInit(&ports);

 ports.GPIO_Mode = GPIO_Mode_OUT;

 ports.GPIO_Pin = GPIO_Pin_1;

 GPIO_Init(GPIOF, &ports);

//***********************************************************************************************

  SPI_StructInit(&spi);

  spi.SPI_Direction = SPI_Direction_1Line_Tx;

  spi.SPI_Mode = SPI_Mode_Master;

  spi.SPI_DataSize = SPI_DataSize_8b;

  spi.SPI_CPOL = SPI_CPOL_High;

  spi.SPI_CPHA = SPI_CPHA_2Edge;

  spi.SPI_NSS = SPI_NSS_Soft;

  spi.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;

  spi.SPI_FirstBit = SPI_FirstBit_MSB;

  spi.SPI_CRCPolynomial = 7;

  SPI_BiDirectionalLineConfig(SPI1, SPI_Direction_Tx);

  SPI_Init(SPI1, &spi);

  SPI_Cmd(SPI1, ENABLE); 

  SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE);

   

//*********************************************************************************************** 

//òåñòîâàÿ ïðîâåðêà ïèíîâ CS RS RST

CS_HIGH;

RSET_HIGH;

RS_HIGH;

CS_LOW;

RS_LOW;

RSET_LOW

}

vik1970va
vik1970vaAuthor
Associate II
November 16, 2018

Sorry for the bad English, the translator is not always able to lend specificity

vik1970va
vik1970vaAuthor
Associate II
November 16, 2018

what's happening:

SPI_SendData8 (SPI1, 0X10); // SPI1-> DR = 0X10; //*(__IO uint8_t*)&SPI1 -> DR = (uint8_t)0X10;

This command should change the BSY: Busy flag = 1 and TXE: Transmit buffer empti = 0 but this does not happen. in the simulator everything works, but in the real board and with the debug not.

waclawek.jan
Super User
November 16, 2018

Read out the SPI control registers content and check.

JW

vik1970va
vik1970vaAuthor
Associate II
November 16, 2018

0690X000006CO5rQAG.png0690X000006CO5mQAG.png Here, the truth is in the simulation, but with real performance it’s all the same.

RCC checked all set up as expected. I don’t even know where to look ... whether to change the microcontroller to the same one or to install the stm32f103�?b on which everything works ....

vik1970va
vik1970vaAuthor
Associate II
November 19, 2018

Hello, spent the weekend to combat this problem.

In the standard setting of the SPI bus, the required signal is present at the MOSI, MISO, CLK outputs and the bus is working, but when trying to switch the bus to the “one line TX�? mode, the DR register is locked to write. MK is working and working fine, to control changed to the same and the result has not changed.

vik1970va
vik1970vaAuthor
Associate II
November 19, 2018

I have already written 3 SPI bus configuration programs:

on registers, CMSIS, HAL and it did not help to solve my problem. Registr DR - READ(ONLY)

vik1970va
vik1970vaAuthor
Associate II
November 25, 2018

Hello. Problem not solved but the task is completed. Solution - writing software implementation Serial Peripheral Interface. In general, the SPI TFT screen is connected to stm32f030f4t6 and works exactly as on STM32F103CBT.

Everyone who tried to help everyone - thank you very much :) I would like the error information to go to the ERATA document.