FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2008 Threads] Internal Flash or EFCPosted 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 EFCPosted 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 EFCPosted 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.
:)
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|