Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic16Device::write_data_memory ( DataBuffer buf,
long  base 
) [protected, virtual, inherited]

Program the data EEPROM contents to the PIC device.

Parameters:
buf A DataBuffer containing the data to program.
base The offset within the data buffer to start retrieving data.
Exceptions:
runtime_error Contains a description of the error along with the address at which the error occurred.

Definition at line 356 of file Pic16Device.cxx.

References PicDevice::COMMAND_BEGIN_PROG, PicDevice::COMMAND_INC_ADDRESS, PicDevice::eesize, Device::io, PicDevice::program_time, Device::progress(), Device::progress_count, Pic16Device::read_ee_data(), THROW_ERROR, IO::usleep(), PicDevice::write_command(), and Pic16Device::write_ee_data().

Referenced by Pic16Device::program().

                                                              {
      unsigned int offset;

      try {
            for(offset=0; offset < this->eesize; offset++) {
                  progress(base+offset);

                  /* Skip but verify blank locations to save time */
                  if((buf[base+offset] & 0xff) == 0xff) {
                        if(read_ee_data() != (uint32_t)(buf[base+offset] & 0xff))
                              break;
                  } else {
                        this->write_ee_data(buf[base+offset]);
                        this->write_command(COMMAND_BEGIN_PROG);
                        this->io->usleep(this->program_time);
                        if(read_ee_data() != (uint32_t)(buf[base+offset] & 0xff))
                              break;
                  }
                  this->write_command(COMMAND_INC_ADDRESS);
                  this->progress_count++;
            }
            if(offset < this->eesize) throw runtime_error("");
      } catch(std::exception& e) {
            THROW_ERROR(runtime_error,
              "Couldn't write data memory at address 0x%04lx", base+offset);
      }
}


Generated by  Doxygen 1.6.0   Back to index