[ARM] Integrating External flash W25Q64FV with EFR32MG21 micro-controller

hrishie89

Newbie
Joined
Oct 19, 2024
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
29
Hello everyone. I've been trying to use external flash W25Q64FV integrating with EFR32MG21 micro-controller.
I am using this driver https://github.com/nimaltd/spif and below is the example code

SPIF_Init(&spif, &hspi1, SPI_CS_GPIO_Port, SPI_CS_Pin);
for(int i=0; i<256;i++){
testwrite=i+45;
}
SPIF_EraseSector(&spif, 0);
SPIF_WritePage(&spif, 0, testwrite, 256, 0);
SPIF_ReadPage(&spif, 0, testRead, 256, 0);

so in this example, I can see that i'm able to read the data which is already there on the flash at address 0;
i can erase that data too using eraseSector but when i try to write the data using WritePage , it is not writing anything, In readPage the values i get are 0xff;

same example with stm32 micro-controller is working fine can write ,read and erase.
 

Your code example should at least show the declaration of involved variables, I'm unable to see if testwrite is correctly pointing to a page buffer and if the buffer is filled with data before calling SPIF_WritePage(). The shown code suggests it's not.
 

#include "spif.h"
uint8_t testwrite[256]={0};
uint8_t testRead[256]={0};
SPIF_HandleTypeDef spif;

They are globally declared.
 

O.k.. How should we help if you are not posting your actual code?
Actually that issue got solved; I removed unnecessary things from the driver.
but now I see if I write 2kb of data i can read that data but if im writing 4kb of data; im not able to read that data it is showing 0 or 0xff.
Below is the code , driver link i already mentioned.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "spif.h"
uint8_t testwrite[2096]={0};
uint8_t testRead[2096]={0};
SPIF_HandleTypeDef spif;
void
app_init (void)
{
  mstimer_init ();
  volatile int a = 100000;
  while (a--)
    ;
  SPIF_Init (NULL, 0);
  for (int i = 0; i < 2096; i++)
    {
      testwrite[I] = i + 16;
    }
 // SPIF_EraseSector (&spif, 0);
//  SPIF_EraseChip(&spif);
//  a = millis();
 // while (millis()-a < 5000);
//
 // SPIF_WritePage (&spif, 0, testwrite, 256, 0);
 // a = millis();
 // while (millis()-a < 500);
//
//  while (1)
//    ;
  //SPIF_ReadPage (&spif, 0, testRead, 256, 0);
}
 
/*****************************************************************************
 * App ticking function.
 ******************************************************************************/
void
app_process_action (void)
{
  SPIF_EraseBlock(&spif, 0);
  SPIF_WriteBlock(&spif, 0, testwrite, 2096, 0);
  SPIF_ReadBlock(&spif, 0, testRead, 2096, 0);
}

 
Last edited by a moderator:

Hi,

did you read the FLASH datasheet?

It says that ERASE takes time, also a WRITE takes time. During this time you usually can not read data (except status) and for sure you can not initiate another WRITE cycle.
I see nothing in your code to care for this timing.
Are you sure the used library takes care for this?

Klaus
 

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…