AnsweredAssumed Answered

flashx example Help

Question asked by Jeremy Sanchez on Aug 27, 2009
Latest reply on Sep 7, 2009 by Jeremy Sanchez


  write_buffer = allocate_buffer(read_write_size, k, "write");
  old_buffer = allocate_buffer(read_write_size, k, "old");
   
     /* fill data to write buffer */
     for ( i = 0; i < read_write_size; i++ ) {
        write_buffer[i] = i;
     } /* Endfor */


     seek_location = 0x0007E000;

     /*read*/
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = read(flash_hdl, old_buffer, read_write_size);
     size_compare(flash_hdl, i, read_write_size);
   
     /*erase*/       
     printf("\nTesting _io_ioctl erase_sector: %d (0x%x)", seek_location, seek_location);
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     error_code = _io_ioctl(flash_hdl, FLASH_IOCTL_ERASE_SECTOR, NULL);
     if (error_code != MQX_OK) {
        printf("\nFLASH_IOCTL_ERASE_SECTOR failed.");
        _task_block();
     }  

     /*write*/
     printf("\nSeek to sector and modify (may take a while)");
     fseek(flash_hdl, seek_location, IO_SEEK_SET);
     i = write(flash_hdl, write_buffer, read_write_size );
     size_compare(flash_hdl, i, read_write_size);

 

I am trying to write and read a "sector" in M52259, but I dont know how to do it. I tried using the code above which comes with the flashx example but it doesnt work. Question is:

 

what doest seek_location means and how to relate that number with an address?

How many bytes does a sector contain?

 

Hope someone can help me.

Outcomes