firebull/STM32-EEPROM-SPI

eeprom polling problem

Closed this issue · 9 comments

Hi everyone
When i use this library , program is locked in eeprom standby mode after correct write!( because always I GOT sEEstatus[0] EQUAL FF, )

i.e Any command that is placed after eeprom write command will not executed!

Any recommendation is appreciated.

  1. PullUP 100k resistors are highly recomended, do you use them?
  2. Can you show the code after which eeprom hangs?

Hi,
1: YES, we used 2 resistors, first one is pull up resistor, (100k) for chip select pin
second resistor (100k) pull down for clock pin.

we can write properly. we have only one problem. in "EEPROM_SPI_WriteBuffer" function, library uses EEPROM_SPI_WritePage function. when we use write function, program executes all functions and in last section when it wants to check if eeprom is not busy ( by reading status register) ( polling), we got sEEstatus[0]=0xFF Always! and that is the problem why software stay in while loop and can not go to the next step. Here is the Polling function from library.

uint8_t EEPROM_SPI_WaitStandbyState(void) {
uint8_t sEEstatus[1] = { 0x00 };
uint8_t command[1] = { EEPROM_RDSR };

// Select the EEPROM: Chip Select low
EEPROM_CS_LOW();

// Send "Read Status Register" instruction
EEPROM_SPI_SendInstruction((uint8_t*)command, 1);

// Loop as long as the memory is busy with a write cycle
do {

    while (HAL_SPI_Receive(&EEPROM_SPI, (uint8_t*)sEEstatus, 1, 200) == HAL_BUSY) {
        osDelay(1);
    };

    osDelay(1);

} while ((sEEstatus[0] & EEPROM_WIP_FLAG) == SET); // Write in progress

// Deselect the EEPROM: Chip Select high
EEPROM_CS_HIGH();

return 0;

I want to mention that instead of osDelay(1); we used HAL_Delay(1);

  1. HAL_Delay is bad idea, as lib is written to use with FreeRTOS. I do not remember for now, but blocking delays can be a reason. I had some kind of problems with it. I need to spend some time do discover.
  2. What about pullUp resistors to WP and HOLD pins?
    eeprom_st_spi
  3. What about SPI params?
    eeprom_spi_settings
  4. Can you read data after you write them and restart the device?

Hi
Thank you for response,

1: I changed the project and now i am using free rtos, my configuration is same as you, ( clock , ...) , now i am using osDelay,

My hardware is same as you, 2 things are different, i am using stm32f4 discover board with stm32f407vgt cpu, and hold pin is connected directly to vcc without pull up resistor.

I tried again, compiled and downloaded it to micro and start to see whats are going in more detail.

-you can use write command without problem and it works.

-you can use read command and it works

But these are the problems

  • if you use 2 write command it will not work
    -if you use 2 read command it will not work

If you use write command then read it will not works

And...

I think there is problem. For example see these shots from project, we go in debug mode, and execute program till line 448, as we expected, RxBuffer must not to change its value( initial value is 0x00), but as we can see in other shot, it will change to 0xFF, and here i think problem is .

I dont know what to do! I am completely confused.

Any suggestion will be appreciated.

Hi everyone
Problem was solved,

Cause for this problem was due to bug in DXP (altium) auto route!! In schematic W protect pin was tied to vcc as datasheet said, but in pcb was not connected. by connecting this pin to vcc, problem solved.

Thank you firebull for help.

Good news!