2015-02-18 03:25 AM
Hello Members,
I am using SPC560D030 for my product. I want to use the Data flash to store the device configuration i.e. I want to use Data flash as NVM. The configuration data is of 120 bytes. I tried reading the reference manual (CD00259063.pdf) on using the Data flash as NVM but may be I am unable to understand on reading/writing to Data flash. I don't find any APIs for it. How can I use the 'DFLASH' for reading or writing? Any example code or document reference will be helpful.Thanks in advance for any help.Mike. #dflash #dataflash #dataflash #orhan-y?lmaz #data-flash2015-04-29 07:06 AM
Hello Orhan ,
yes but it is an offset fromSPC5_DFLASH_BASE.
bool
spc5_dflash_write_word(uint32_t address, uint32_t word) {
bool
result;
osalDbgAssert((address & 3) == 0,
''unaligned write''
);
/* Marking for program.*/
DFLASH.MCR.R = 0x00000010;
/* PGM */
/* Starting operation.*/
*((volatile uint32_t *)(SPC5_DFLASH_BASE + address)) = word;
Best regards
Erwan
2015-04-29 07:23 AM
#define DFLASH_BASE_ADDR 0x00800000
...
Addr = DFLASH_BASE_ADDR;
..
DFLASH.MCR.R = 0x00000010;
(*(U_32 *)Addr) = data;
DFLASH.MCR.R = 0x00000011;
while(!(DFLASH.MCR.R & 0x00000400));
DFLASH.MCR.R = 0x00000010;
DFLASH.MCR.R = 0x00000000;
but not work!
Thanks
2015-04-30 12:49 AM
Hello Orhan ,
I have tested the code this morning. Your code is working well , you have just to erase the block before writing a word. Did you initialize correctly the driver before ? (Cf Giovanni's code)/**
* @brief Initializes the driver.
*/
void
spc5_dflash_init(
void
) {
/* Fixes wrong initialization in HAL driver.*/
// CFLASH.PFCR1.R = 0x318D8081;
CFLASH.PFCR1.B.BK1_APC = 3;
CFLASH.PFCR1.B.BK1_RWSC = 6;
/* Unlock procedure.*/
DFLASH.LML.R = 0xA1A11111;
DFLASH.LML.B.LME = 1;
DFLASH.SLL.R = 0xC3C33333;
DFLASH.SLL.B.SLE = 1;
DFLASH.MCR.R = 0x0;
/* All blocks unlocked.*/
DFLASH.LML.B.LLK = 0;
DFLASH.SLL.B.SLK = 0;
}
Best regards
Erwan
2015-06-01 07:52 AM
2016-02-25 09:49 PM
Hi Erwan,
I am using data flash on SPC560P40L1, and the eemprom emulation driver is used provided by spc5studio v3.7.There is something wrong when initialize, the return error code is 0x40(EE_ERROR_PE_OPT). However, the same code is running well on SPC560P50L5, and I need your help.I donot know where the problem is?Thanks. /* Init EEPROM.*/ result = FSL_InitEeprom(&eepromConf, NULL_CALLBACK); if (result != EE_OK && result != EE_FIRST_TIME_INITIALIZATION) { //while (sd_lld_write(&SD1,(uint8_t*)''INIT ERROR\r\n'', 12) == SERIAL_MSG_WAIT); //return result; } /* Read dataID 0.*/ result = FSL_ReadEeprom(&eepromConf, 0, (UINT32)(dtc_ram), NULL_CALLBACK);2016-02-26 01:19 AM
Hello,
currently ee library only support SPC560P50 devices. We are introducing the support for SPC560P40/34 and this library will be available in the next version of SPC5Studio. Meanwhile, you can use the zip attached to solve the problem.In your project for P40 please replace the following files: - eed.a - eed_emulation,h Please not thatIn the next version, the eed.a library will support both devices.
Sorry for the inconvenience. Regards Procolo ________________ Attachments : EEPROM.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Rs&d=%2Fa%2F0X0000000bZ4%2FdiL1XG101T81E3TbslvnKv2nAr1swzYyty2.vN3pQ9Y&asPdf=false2016-04-06 11:57 PM
thanks.