Hi,
i need EEPROM example code for FRDMK64f120 controller. am using KDS 2.0 and KSDK 1.1.0 example. so how to write and read
data from EERPOM.
thanks and regards,
sudhakar p
Solved! Go to Solution.
Hi Sudhakar,
Once the flash is programmed/written, you can read it with a pointer.
Example code....haven't tested yet as short on time today.
void *dst;
uint32_t FlashValueAtFA00;
uint32_t FlashValueAtFA04;
*((uint32_t *)&dst) = 0xFA000;;
FlashValueAtFA00 = ((uint32_t *)dst);
FlashValueAtFA04 = ((uint32_t *)dst+4);
Regards,
David
Hi,
I would like to know EEPROM example code for MIMXRT1176 for cm4 and cm7. I am using LPCXpresso54628 EEPROM code as an example. So how to read and write data from/to EERPOM.
regards,
Meher V
I would like to know how I can write and read an integer (uint32) in the FLASH memory of the FRDM K64 board?
I saw the example in [KDSK_1.2.0\examples\frdmk64\driver_examples\flash\mdk\flash_example_uvprojx] and it works fine.
However, I would like to do the same task using MQX. Anyone would have any ideas. Or where can I find some example with MQX?
I have same question,thanks.
hi David,
i tried this method, here i am not getting any error, but whatever data i written into the flash that data i am not getting its displaying some other data,
PROGRAM:
uint8_t sudha_data[100]="write data";
destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
ret = FlashProgram(&flashSSDConfig,destination,80,sudha_data, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Read on P-Flash */
destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
ret = FlashReadOnce(&flashSSDConfig, destination, sudha_data, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Message to user */
p_data = (uint32_t *)&sudha_data;
printf("\n\n\r---->Reading flash IFR @ location 0x%x: 0x%x", (unsigned int)destination, (unsigned int)(*p_data));
please give some solution for this..
Hi Sudhakar,
Please review the flash example code:
C:\Freescale\KSDK_1.1.0\demos\flash_demo\src
Regards,
David
Hello David,
using that flash demo code only i edited above code. in flash example project there is no flash write operation API function. i want to write 4KB data into flash and again i want to READ that data. can you give solution for this..? could you tell which function i want to use..? can you give simple example code for this... just see my code also whatever previously i posted. and give some solution for this.
Thanks and regards,
sudhakar p
hi David,
i am waiting for your reply..
is possible or not.? minimum 2kb data i want to write into internal flash and i want to read.
give some idea. i saw example code also but that one was not working. i mean i am doing some mistake i dnt know exact.
i tried both function
WRITE OPERATION:
1) ret = FlashProgram(&flashSSDConfig, destination, size, program_buffer, g_FlashLaunchCommand);
2)ret = FlashProgramOnce(&flashSSDConfig,0x2,buff_data, g_FlashLaunchCommand);
READ OPERATION:
ret = FlashReadResource(&flashSSDConfig,destination,sudha_data,0x0, g_FlashLaunchCommand);
may be i am doing mistake in "destination address". so can you edit code like 2kb data WRITE and READ from flash..
Thanks and regards,
sudhakar p
Hi Sudhakar,
I think you are heading in the right direction but...
Why are you trying to write to the Flash IFR Register?
Once you issue the FlashProgram(); operation you should be able to read the Flash memory directly and not have to use a Flash Driver function call.
In the flash example code once I step over the following call (
result = FlashProgram(&flashSSDConfig, destAdrss, BUFFER_SIZE_BYTE, \
buffer, g_FlashLaunchCommand);
), I can see the Memory window contents change from all F's to the programmed values shown below.
Please note that KDS/KSDK updates have been posted and I'm now using it.
Reference: New Kinetis Design Studio V3.0.0 available
Regards,
David
Hi David,
i need more information. using FlashProgram() i will write data its ok. but how i will read that data again..?
if i use
ret = FlashReadResource(&flashSSDConfig,destination,sudha_data,0x0, g_FlashLaunchCommand); its showing error "halted due to flash error". how can i read that data.
"i am writing some CONFIGURATION PARAMETER like ip address, gateway,baudrate etc., in power on condition user will configure this things using serial terminal, after user configuration i will write that data into internal flah.after device reset condition or next power on condition i want to read that data from internal flash,so user dnt want to configure again and again, whatever previous they configured i will use that parameter values "
thanks and regards,
sudhakar p
Hi Sudhakar,
Once the flash is programmed/written, you can read it with a pointer.
Example code....haven't tested yet as short on time today.
void *dst;
uint32_t FlashValueAtFA00;
uint32_t FlashValueAtFA04;
*((uint32_t *)&dst) = 0xFA000;;
FlashValueAtFA00 = ((uint32_t *)dst);
FlashValueAtFA04 = ((uint32_t *)dst+4);
Regards,
David
Hi David,
i got it. Thank you very much. i used following step
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unsigned char *dst;
dst=0xFA000;
printf("\n\rDATA start\n\r");
for (i = 0; i < BUFFER_SIZE_BYTE; i++)
{
FlashValueAtFA00 = *dst;
printf("%d",FlashValueAtFA00);
dst++;
}
printf("\n\rDATA END\n\r");
regards,
sudhakar p
Hi David,
i tried your code but i am not getting whatever data i wrote. i included that for your reference,
destination = flashSSDConfig.PFlashBase + (flashSSDConfig.PFlashSize - 6*FTFx_PSECTOR_SIZE);
for (i = 0; i < BUFFER_SIZE_BYTE; i++)
{
program_buffer[i] = 'A';
}
size = BUFFER_SIZE_BYTE;
ret = FlashProgram(&flashSSDConfig, destination, size, \
program_buffer, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
printf("\n\r\tSuccessfully Programmed and Verified Location 0x%x -> 0x%x", (unsigned int)destination, (unsigned int)(destination + size));
/////////////////////////////////////////////////////////////////////////////////////
/* Read on P-Flash */
*((uint32_t *)&dst) = 0xFA000;;
FlashValueAtFA00 = ((uint32_t *)dst);
FlashValueAtFA04 = ((uint32_t *)dst+4);
printf("\n\rDATA 1=%d",FlashValueAtFA00);
printf("\n\rDATA 2=%d",FlashValueAtFA04);
This printf function i am getting
DATA 1=1024000
DATA 2=1024016
but i wrote "A" character at this address. can you please tell what mistake i did..?
thanks and regards,
sudhakar p
Hi DAVID,
here i am going to write one Structure. so i can't read long by long data. example
struct config_params
{
unsigned char ip_array[10];
unsigned char gateway_array[10];
unsigned char netmask_array[10];
}struct config_params exist_params;
struct config_params default_params =
{
"192.168.0.64", //ip
"192.168.0.210", , //gate
"255.255.255.0", //net
};
ret = FlashProgram(&flashSSDConfig, destination, sizeof(exist_params), \
&exist_params, g_FlashLaunchCommand);
DAVID is the above method will work for flash write..?
using"flashprogram" API i will write this data into flash. but how can i recover(READ) this data..?
thanks and regards,
sudhakar p
Hi Sudhakar,
Please review following example:
C:\Freescale\KSDK_1.1.0\demos\i2c_rtos\src
It contains master and slave i2c code. I'm assuming your eeprom device has i2c interface. Correct?
If yes, then you need to reference master i2c code.
Project locations:
C:\Freescale\KSDK_1.1.0\demos\i2c_rtos\i2c_rtos_mqx\kds\frdmk64f
Regards,
David
Hi David,
i want to store some data into NVM. but FRDMK64FN1MOVDC12 does not have EEPROM. so i planned to store data into flash memory. so i tried following method but i am getting error message.
char data[]="hi";
destination = flashSSDConfig.PFlashBase + PFLASH_IFR; /* Start address of Program Once Field */
ret = FlashProgram(&flashSSDConfig, destination, sizeof(data), data, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
can you give any idea to write data into the internal FLASh.
actually i want to store one "structure" into the flash. like.,
struct config_params{
uint32_t localipaddr; //
uint32_t localnetmask; //
uint32_t gatewayaddr; //
uint8_t baudrate; //
uint8_t baudrate1; //
uint8_t dataparams; //
uint8_t dataparams1; //
};
give some example for "READ AND WRITE" data into the Flash.
thanks and regards,
sudhakar p