AT32UC3C0512C FLASH WRITE PROBLEM

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi , i hope someone can give me an input on this headscratcher,

I have a UC3C0512C  that i try to write some data into the flash memory,

I can write to the RAM on 0x00000400, The user page on 0x8080000 but not to the ordinary flash memory on 0x8007FE00.

The memory simply remains as 0xFF 's

The routine flashc_write_page(1022) issues the correct write command to the flash controller 0XA503FE01, but nothing changes in the memory.

I attach the test code and hope for a helping hand ;-)

BR

Lars Hansen

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

flashc_write_page(1022); //write it to location page 1022


I calculate the byte offset 0x7fe00 to be in page 1023.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Mikech,

 

That is correct , my fault. But it does not matter which address i use, nothing are written.

 

Writing to the RAM location (Not using the Flashc_XXX routines ofcourse) proves that the pointer system works.

 

Writing to the Userpage , using the Flashc_XXXXX_userpage functions proves that those functions actually can access the flash

 

Writing to the program flash memory using the flashc_erase/write etc functions does not change anything in the flash.

I have verified that the flash cmd register are loaded with correct values, this creates my frustration .

 

Maybe i user the wrong page buffer adress, do you have any recommendation ??

 

Best Regards

Lars Hansen 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Mikech

 

I tried to write on several page locations, now i get data in the flash but in sometimes weird locations.

 

It seems that i do the page alignment wrong somehow, will investigate closer  monday.

 

have a nice weekend

 

Lars

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In your original code snippet you do not initialise the counter i_flash_data which (depending on what your code does now), could produce unexpected patterns.
I would initialise i_dump_data to the page-number you intend to write to.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

afaik the idea is to: 1)set the flash bufferpage to the area you want to flash 2)write simply to that location 3)once the page is full, flash write with erase should first erase the page and then copy the buffer in (thats what flashc_memcpy does)

also check if generic clock and your bus clock (external osc, pll, etc) match, I had alot problems when I tried to use the flash controller in a different speed than the bus speed

 

greetz

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Mikech and others,

 

I have solved the problem , apparently you have to write a whole page at the time.

My basic confusion was from the Atmel datasheet that mentions the page buffer to write with no address what so ever, and the explanation about the location  / addressing method is very

foggy in the datasheet. The page buffer are shown as 64 X 32 bit word but  have to be 128 word in order to write correct. 

 

following crude code writes any page I want, with the exception of flash locations below the program start address, I yet have to find out the reason for this behavior.

 


void write_flash_page(int i_page)
{

uint32_t *i_flashadress  = (uint32_t *) (FLASH_START + (FLASH_PAGE * i_page));

 uint8_t i_flash_data;
 uint32_t i_dump_data;                                                                  //the data to write in the location

 i_flash_data = 0;
 flashc_clear_page_buffer();                                                            // first clear the page buffer
 flashc_erase_page(i_page,1);                                                             //erase the page to write
 while (!flashc_is_page_erased())
 {
 }

 for (int k = 0;k<128;k++)                                                               //always write one full page
 {
  
  *i_flashadress = i_data_to_flash[k];                                                //dump the data buffer to the pointed location
  i_flashadress = i_flashadress + 1;                                                 //increment address location (location are incremented by one if byte, by 4 if uint32_t)
 }
 //end test of pointers, the page are filled
 flashc_write_page(i_page);                                                            //write it to location page 1022
 //flashc_write_user_page();
 
}

Thanks for you help

 

BR

Lars   

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That "Mapping from Page Buffer to flash" diagram would be correct for a 256 byte pagesize., but the pagesize in the UC3Cxxx is 512 bytes.


There is no need to write to all the words in the page-buffer, the important thing is to clear the page-buffer because the page-buffer does not operate like 'normal' RAM.,
ie. '0's in your data will set those bits in the page-buffer to 0 but the '1's do nothing.