Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic16Device::bulk_erase ( void   )  [protected, virtual, inherited]

Bulk erase the program and data memory of a flash device.

Precondition:
The device has flash memory.

Code protection on the device is verified to be completely off.

The device is turned completely off.

Postcondition:
The device is turned completely off.
Exceptions:
runtime_error Contains a description of the error.

Reimplemented in Pic16f8xxDevice, Pic16f87xADevice, and Pic16f6xxDevice.

Definition at line 258 of file Pic16Device.cxx.

References PicDevice::COMMAND_BEGIN_PROG, PicDevice::COMMAND_ERASE_DATA_MEM, PicDevice::COMMAND_ERASE_PROG_MEM, PicDevice::COMMAND_LOAD_CONFIG, PicDevice::erase_time, PicDevice::flags, Device::io, PIC_FEATURE_EEPROM, PicDevice::pic_off(), PicDevice::set_program_mode(), IO::shift_bits_out(), IO::usleep(), PicDevice::write_command(), and Pic16Device::write_ee_data().

Referenced by disable_codeprotect(), Pic12f6xxDevice::disable_codeprotect(), and Pic16Device::erase().

                                 {
      try {
            /* Bulk Erase Program Memory */
            /*   Set PC to config memory (to erase ID locations) */
            /*   Do a "Load Data All 1's" command. */
            /*   Do a "Bulk Erase Program Memory" command. */
            /*   Do a "Begin Programming" command. */
            /*   Wait erase_time to complete bulk erase. */
            this->set_program_mode();
            this->write_command(COMMAND_LOAD_CONFIG);
            this->io->shift_bits_out(0x7ffe, 16, 1);
            this->io->usleep(1);
            this->write_command(COMMAND_ERASE_PROG_MEM);
            this->write_command(COMMAND_BEGIN_PROG);
            this->io->usleep(this->erase_time);

            if(this->flags & PIC_FEATURE_EEPROM) {
                  /* Bulk Erase Data Memory */
                  /*   Do a "Load Data All 1's" command. */
                  /*   Do a "Bulk Erase Data Memory" command. */
                  /*   Do a "Begin Programming" command. */
                  /*   Wait erase_time to complete bulk erase. */
                  this->write_ee_data(0x00ff);
                  this->write_command(COMMAND_ERASE_DATA_MEM);
                  this->write_command(COMMAND_BEGIN_PROG);
                  this->io->usleep(this->erase_time);
            }
            this->pic_off();
      } catch(std::exception& e) {
            this->pic_off();
            throw;
      }
}


Generated by  Doxygen 1.6.0   Back to index