SST26VF064B With XMEGA256A3BU

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, I'm trying to save data to an external memory (SST26VF064B) by an XMEGA256A3BU simply via SPI.

Actually i can read JEDEC ID without problems.

I think to be able to read memory but I'm not so shure because i can't write data to the memory.

 

I use SPID and i set it in this way. <SPID_CTRL = 0x5E;>

<delay = 0x0A; is 100µs time

 spi_sett_w = spi_sett_r  = 0x00;
 spi_sett_w = spi_page_r =  0x00;
 spi_byte_w  = spi_byte_r = 0x00;>

 

<void SPI_CS_pause (void)

    {
    bit_write (&PERIF_OUT, SPI_CS, 0x01);                            /* DISABILITA CS  */
    delay = 0x0F;
    bit_write (&PERIF_OUT, SPI_CS, 0x00);                            /* ABILITA CS  */
    delay = 0x0A;

>

 

I start my writing sequence as below:

 

bit_write (&PERIF_OUT, SPI_CS, 0x01);                            /* DISABLE CS  */
    delay = 0x0A;
    bit_write (&PERIF_OUT, SPI_WP, 0x01);                            /* DISABLE HARDWARE WRITE PROTECTION */
    delay = 0x0A;
    bit_write (&PERIF_OUT, SPI_CS, 0x00);                            /* ENABLE CS  */
    delay = 0x0A;

    dato_spi = SPI_data_transfer(0x06);                                /* WRITE ENABLE COMMAND */
    dato_spi = 0xFF;
    
    SPI_CS_pause ();
    
    dato_spi = SPI_data_transfer(0x05);                                /* STATUS REGISTER READING */
    
    while ((dato_spi & 0x02) != 0x02)                                /* WAIT FOR WRITE ENABLE BIT */
    {
        dato_spi = SPI_data_transfer(0xFF);
    }
    
    dato_spi = 0xFF;
    
    dato_spi = SPI_data_transfer(0x05);                                /* STATUS REGISTER READING */
    
    while ((dato_spi & 0x1F) != 0x02)                                /* WAIT FOR PENDING WRITE STATE*/
    {
        dato_spi = SPI_data_transfer(0xFF);
    }
    
    SPI_CS_pause ();

>

 

My write sequence is this:

 

< dato_spi = SPI_data_transfer(0x02);                         /* PAGE PROGRAM COMAND*/
    dato_spi = SPI_data_transfer(spi_sett_w);               /* WRITE ADDRESS */
    dato_spi = SPI_data_transfer(spi_page_w);             /* WRITE ADDRESS */
    dato_spi = SPI_data_transfer(spi_byte_w);              /* WRITE ADDRESS */
    dato_spi = SPI_data_transfer(0x02);                        /* WRITE DATA */
    dato_spi = SPI_data_transfer(0x04);                        /* WRITE DATA */
    dato_spi = SPI_data_transfer(0x06);                        /* WRITE DATA */
    dato_spi = SPI_data_transfer(0x08);                        /* WRITE DATA */

   SPI_CS_pause ();

>

 

Thank you for help.

 

Silvio

 

 

 

This topic has a solution.
Last Edited: Mon. Nov 25, 2019 - 10:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps a Moderator can lock this Thread and any discussion can be held on the copy.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Buy JC, what happen, what i wrong to lock my help request?

 

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not seeing "another copy" in recent history. 

Letting the smoke out since 1978

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gigatrek,

 

Your post is fine!

There were two copies of it on the Forum, and my comment was for a Moderator to lock one, so that any replies would all be kept to the same Thread.

You likely clicked the Post button twice... 

 

It appears that the copy with my comment is the only remaining version on the Forum.

 

Good luck with your project!

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you DocJC,

I excuse me for my mistake, but i remember that when i click the post button the screen don't change and the button remain some hours after.

 

nice day

 

Silvio

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hello, surfing the internet i have find the solution.

 

Every time you power up the SST26VF064B flash memory, its " global write protection" is enabled.

 

This protection will be disable only with an ULBPR command, and all comands, WREN, Write etc will be ignored

 

When you power on your system, before to use this flash memory you must send an ULBPR, after every thing I have writed above works good.

 

Nice day