cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot communicate with ext SPI Flash

EDuat.1
Associate III

Hey guys,

I am trying to communicate with S25FL064L Cypress Flash and almost for one week I cant reach the redec ID , I checked the hardware, and communication with digital analyzer just with S25FL064L no any hardware.Tried the HAL library , checked the websites and compare with my codes, I couldn'd find a mistake, so where is my mistake now.Thank you for answers and spending time.These are codes related.

int main(void)
{
	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
 
	SystemClock_Config();
	//  0xEBFF FCFF for port A
	//  0xFFFF FFFF for the other ports
// I have read some info from the users and that is why this code is below
	CLEAR_REG(CS_FLASH_GPIO_Port->MODER);
 
	MX_GPIO_Init();
	MX_SPI1_Init();
	MX_SPI2_Init();
	MX_USART1_UART_Init();
	MX_USART2_UART_Init();
	MX_ADC_Init();
	MX_RTC_Init();
	MX_I2C1_Init();
 
	LL_SPI_Enable(SPI1);
}
 
void read_Jedec_ID(uint8_t *p)
{
	LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_15);
	spi_transmit_receive(SPI1, SPI_RDID_CMD);//0x9F
 
	for (uint8_t i = 0; i < 8; i++)
	{
		p[i] = spi_transmit_receive(SPI1, 0x00);
	}
 
	LL_GPIO_SetOutputPin(CS_FLASH_GPIO_Port, CS_FLASH_Pin);
 
}
 
uint8_t spi_transmit_receive(SPI_TypeDef *SPIx, uint16_t val)
{
	uint8_t ret_val;
 
	while (!(READ_BIT(SPI1->SR, SPI_SR_TXE) == (SPI_SR_TXE)))
			;
	LL_SPI_TransmitData8(SPIx, (uint8_t)val);
 
	while (!(READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)))
		;
	ret_val = LL_SPI_ReceiveData8(SPIx);
 
	return ret_val;
}

1 ACCEPTED SOLUTION

Accepted Solutions
EDuat.1
Associate III

Okay, it is solved.Our hardware designer draws incorrecty the MOSI-MISO pins.

View solution in original post

3 REPLIES 3

What STM32 part?

Show signals as observed via ​logic analyzer.

Describe the pins and interfaces, I'm not going to wade through an IOC file on my phone.

I don't understand what the MODER write does before any of the clocks or interfaces are up.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
EDuat.1
Associate III

Show signals as observed via ​logic analyzer.

We dont need it because I already got the value from it(Digital Discovery Digilent)

I don't understand what the MODER write does before any of the clocks or interfaces are up.​

Because I tried something unnecessarly because of I read something on the websites that someone did it and works(interesting).Just get rid of it.

EDuat.1
Associate III

Okay, it is solved.Our hardware designer draws incorrecty the MOSI-MISO pins.