Skip to main content
Ali sadeghi
Associate III
March 16, 2021
Solved

How can i read from flash in spc560b ?

  • March 16, 2021
  • 4 replies
  • 2369 views

Hi Friend

I want Read from speciefic address in flash and save it In ram and then write to another Address in flash. My problem is how can i read from flash.

I am waiting for your help

    This topic has been closed for replies.
    Best answer by zambrano.luigi

    Hi,

    in order to read the Flash memory, it is enough to use a pointer to the address you want to read. The following code shows how to read the content of the flash memory at the address 0xFC0000.

    /* Inclusion of the main header files of all the imported components in the
     order specified in the application wizard. The file is generated
     automatically.*/
    #include "components.h"
     
    /*
     * Application entry point.
     */
    int main(void) {
     
     uint32_t flash_address_pointer = 0xFC0000;
     vuint32_t flash_value;
     
     flash_value = *((vuint32_t*)(flash_address_pointer));
     
     /* Initialization of all the imported components in the order specified in
     the application wizard. The function is generated automatically.*/
     componentsInit();
     
     /* Enable Interrupts */
     irqIsrEnable();
     
     
     /* Application main loop.*/
     for ( ; ; ) {
     printf("Address = 0x%08X - Value = 0x%08X\n\r", (unsigned int)flash_address_pointer, (unsigned int)flash_value);
     pal_lld_togglepad(PORT_E, LED_4);
     pal_lld_togglepad(PORT_A, LED_3);
     pal_lld_togglepad(PORT_D, LED_5);
     osalThreadDelayMilliseconds(250);
     }
    }

    Regards,

    Luigi

    4 replies

    Ali sadeghi
    Associate III
    March 17, 2021

    my code is

    uint32_t *p=0x000000AC;

     int myvar[8] ;

     for(uint8_t jj=0;jj<8;jj++)

    {

    myvar[jj] = *p ;

    }

    the output is constant. whats my problems code?

    zambrano.luigi
    ST Employee
    March 17, 2021

    Hi,

    if you use SPC5Studio, it includes a lot of example. One of this (SPC560Bxx_RLA Flash Test Application for Discovery) shows you how to use the integrated Flash Driver that allows you to read/write/erase the Flash Memory.

    Regards,

    Luigi

    Ali sadeghi
    Associate III
    March 17, 2021

    Hi my deer friend

    you are right spc studio has a lot of example like you mentioned it but unfortunately read function isnt one of them.

    I send you a list of function that work in flash operation0693W000008xBi9QAE.pngas you can see in UM1627 user manual and this pic there isnt read function.

    I try pointer solution to get read flash but it doesnt work.

    I am waiting for your answer

    thanks a lot man

    Tesla DeLorean
    Guru
    March 17, 2021

    >>the output is constant. whats my problems code?

    You don't advance the pointer

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Ali sadeghi
    Associate III
    March 20, 2021

    the output data isnt correct according to the address.

    Ali sadeghi
    Associate III
    March 20, 2021

    Hi Luigi

    I apologize for my delay

    thanks for your answer

    I report my result after use that code.