Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists