Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic18Device::erase ( void   )  [virtual]

Erase the memory contents of the device. This is only applicable to EEPROM or flash devices that can be electronically erased.

Precondition:
set_iodevice() must have been called with a valid IO object.
Exceptions:
runtime_error Contains a textual description of the error.

Implements Device.

Definition at line 63 of file Pic18Device.cxx.

References COMMAND_CORE_INSTRUCTION, COMMAND_TABLE_WRITE, PicDevice::erase_time, Device::io, PicDevice::memtype, PicDevice::pic_off(), PicDevice::set_program_mode(), set_tblptr(), IO::usleep(), and write_command().

                            {
      if(this->memtype != MEMTYPE_FLASH)
            throw runtime_error("Operation not supported by device");

      try {
            set_program_mode();

            set_tblptr(0x3c0004);
            write_command(COMMAND_TABLE_WRITE, 0x0080);     /* "Chip Erase" */
            write_command(COMMAND_CORE_INSTRUCTION, 0x0000); /* nop */
            write_command(COMMAND_CORE_INSTRUCTION, 0x0000); /* nop */
            this->io->usleep(this->erase_time);

            pic_off();
      } catch(std::exception& e) {
            pic_off();
            throw;
      }
}


Generated by  Doxygen 1.6.0   Back to index