Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Internal Flash or EFC

Posted by Allure99 on July 15, 2008
Dear all,
HW: AT91SAM7x
Compiler: CrossWork GCC
OS: FreeRTOS 4.7

Any one has experience using the internal flash memory as an EEPROM data storage?
It is call Embedded Flash Controller (EFC) for AT91SAM7 family.

Any help on read and write on the last page of flash memory area in FreeRTOS will be much appreciate.

Thanks for ur attention

Regards
Hudson

RE: Internal Flash or EFC

Posted by Çağlar Akyüz on July 16, 2008
#define FLASH_PAGE_SIZE 256
#define FLASH_BASE_ADDRESS 0x00100000
#define SETTINGS_PAGE_NUMBER 1023
#define SETTINGS_PAGE ((int *)0x0013FF00)

/*
* I think this is not the best way to go but we need to
* put flash routines into the sram
*/
char flash_write(int *data, short data_length, short pagen) __attribute__ ((section (".data")));
inline int perform_command( char command, short pagen ) __attribute__ ((section (".data")));

void efc_test()
{
SETTINGS_PAGE[0] = 1; /* write sth to the beginning */
SETTINGS_PAGE[32] = 1;
SETTINGS_PAGE[64] = 1; /* write sth to the end */

flash_write(NULL, 0, SETTINGS_PAGE_NUMBER);
}

/*
* Flash programming
*/

inline int perform_command( char command, short pagen )
{
int i;

DISABLE_INTERRUPTS();

i = AT91C_BASE_MC->MC_FSR;
while( ( i & AT91C_MC_FRDY ) != AT91C_MC_FRDY )
i = AT91C_BASE_MC->MC_FSR;

AT91C_BASE_MC->MC_FCR = ( 0x5A << 24 ) | command | ( pagen << 8 );

i = AT91C_BASE_MC->MC_FSR;
while( ( i & AT91C_MC_FRDY ) != AT91C_MC_FRDY )
i = AT91C_BASE_MC->MC_FSR;

ENABLE_INTERRUPTS();

return i;
}
char flash_write(int *data, short data_length, short pagen)
{
int *addr_ptr = (int *)(FLASH_BASE_ADDRESS + pagen * FLASH_PAGE_SIZE);
int i;

if(data != NULL) {
for(i = 0; i < data_length; i++)
addr_ptr = data;
}

i = perform_command( AT91C_MC_FCMD_START_PROG , pagen );

if(( i & AT91C_MC_LOCKE ) == AT91C_MC_LOCKE )
return 1;

if(( i & AT91C_MC_PROGE ) == AT91C_MC_PROGE )
return 2;

return 0;
}

RE: Internal Flash or EFC

Posted by Allure99 on July 17, 2008
Thanks for your Help chaalar.

I am using "__attribute__ ((section (".fast")" instead of .data. but i guess they both put flash routines into the sram.

:)


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner