Quantcast
Channel:
Viewing all articles
Browse latest Browse all 59170

Forum Post: RX63T Write/Erase Operation

$
0
0
Hi, I am facing a problem while writing data to data flash memory of RX63T.I am using the API given in sample code of RX63N. I am trying to write 2 bytes of data(any data) but complete data flash memory is getting updated with data 0x80.I am using e2studio with KPIT GNU compiler.The definition of functions used in my code for write operation are described below. First i am calling the function to initialize data flash memory and then calling the function to enable data flash memory read and program access which are as follows: uint8_t DFM_initializeFlash ( void ) { // Declare iteration counter variable uint16_t wait_cnt // Disable FCU interrupts in FCU block FLASH. FAEINT . BIT . ROMAEIE = 0; FLASH. FAEINT . BIT . CMDLKIE = 0; FLASH. FAEINT . BIT . DFLAEIE = 0; FLASH. FAEINT . BIT . DFLRPEIE = 0; FLASH. FAEINT . BIT . DFLWPEIE = 0; // Disable FCU interrupts in ICU // Disable flash interface error (FIFERR) IPR(FCU, FIFERR) = 0; IEN(FCU, FIFERR) = 0; // Disable flash ready interrupt (FRDYI) IPR(FCU, FRDYI) = 0; IEN(FCU, FRDYI) = 0; // Before writing data to the FCU RAM, clear FENTRYR to stop the FCU. if (FLASH. FENTRYR . WORD != 0x0000) { // Disable the FCU from accepting commands - Clear both the // FENTRY0(ROM) and FENTRYD(Data Flash) bits to 0 FLASH. FENTRYR . WORD = 0xAA00; // Initialize timeout for FENTRYR being written. wait_cnt = FLASH_FENTRYR_TIMEOUT; // Read FENTRYR to ensure it has been set to 0. Note that the top byte // of the FENTRYR register is not retained and is read as 0x00. while (0x0000 != FLASH. FENTRYR . WORD ) { // Wait until FENTRYR is 0 unless timeout occurs. if (wait_cnt-- = 0) { // This should not happen. FENTRYR getting written to 0 should // only take 2-4 PCLK cycles. return FLASH_FAILURE; } } } // Return no errors return FLASH_SUCCESS; } void DFM_accessDataFlash ( uint16_t read_en_mask, uint16_t write_en_mask) { // Used for making sure select bits are not set. uint16_t temp_mask = 0x00FF; // Set Read access for the Data Flash blocks DB0-DB7 FLASH. DFLRE0 . WORD = 0x2D00 | (read_en_mask & temp_mask); // Set Read access for the Data Flash blocks DB8-DB15 FLASH. DFLRE1 . WORD = 0xD200 | ((read_en_mask 8) & temp_mask); // Set Erase/Program access for the Data Flash blocks DB0-DB7 FLASH. DFLWE0 . WORD = 0x1E00 | (write_en_mask & temp_mask); // Set Erase/Program access for the Data Flash blocks DB8-DB15 FLASH. DFLWE1 . WORD = 0xE100 | ((write_en_mask 8) & temp_mask); } And finally i am calling the function to write data to data flash memory which is as follow: uint8_t DFM_writeBytestoFlash ( uint32_t address, uint16_t data, uint8_t size) { // Declare wait counter variable int32_t wait_cnt; // Check data size is valid if (DF_PROGRAM_SIZE_SMALL == size) { // Perform bit shift since 2 bytes are written at a time size = size 1; // Send command to data flash area *( FCU_BYTE_PTR )DF_ADDRESS = 0xE8; // Specify data transfer size to data flash area *( FCU_BYTE_PTR )DF_ADDRESS = size; // Copy data from source address to destination area *(F CU_WORD_PTR )address = data; // Write the final FCU command for programming *( FCU_BYTE_PTR )(DF_ADDRESS) = 0xD0; // Set the wait counter with timeout value wait_cnt = WAIT_MAX_DF_WRITE; // Check if FCU has completed its last operation while (FLASH. FSTATR0 . BIT . FRDY == 0) { // Decrement the wait counter wait_cnt--; // Check if the wait counter has reached zero if (wait_cnt == 0) { // Maximum time for writing a block has passed, // operation failed, reset FCU DFM_resetFlash(); // Return FLASH_FAILURE, operation failure return FLASH_FAILURE; } } // Check for illegal command or programming errors if ((FLASH. FSTATR0 . BIT . ILGLERR == 1) || (FLASH. FSTATR0 . BIT . PRGERR == 1)) { // Return FLASH_FAILURE, operation failure return FLASH_FAILURE; } } // Data size is invalid else { //Return FLASH_FAILURE, operation failure return FLASH_FAILURE; } // Return FLASH_SUCCESS, operation success return FLASH_SUCCESS; } Kindly help to resolve this problem. Thanks & Regards, Prija nair.

Viewing all articles
Browse latest Browse all 59170

Trending Articles