2021-03-16 05:44 AM
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
Solved! Go to Solution.
2021-03-18 12:07 AM
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
2021-03-17 04:27 AM
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?
2021-03-17 08:21 AM
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
2021-03-17 09:31 AM
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 operationas 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
2021-03-17 01:58 PM
>>the output is constant. whats my problems code?
You don't advance the pointer
2021-03-18 12:07 AM
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
2021-03-20 02:44 PM
Hi Luigi
I apologize for my delay
thanks for your answer
I report my result after use that code.
2021-03-20 02:47 PM
the output data isnt correct according to the address.
2021-03-27 09:07 PM
Hi luigi
Your code work.
Thanks for your time