Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic16Device::read_program_memory ( DataBuffer buf,
long  base = 0,
bool  verify = false 
) [protected, virtual, inherited]

Read the entire contents of program memory from the PIC device.

buf A DataBuffer in which to store the read data.
base The offset within the data buffer to start storing data. If this parameter isn't specified, it defaults to 0.
verify If this flag is true, don't store the data in the DataBuffer but verify the contents of it.
The PIC should have it's program counter set to the beginning of program memory.
The program counter is pointing to the address immediatly after the last program memory address.
runtime_error Contains a description of the error along with the address at which the error occurred.

Definition at line 328 of file Pic16Device.cxx.

References PicDevice::codesize, PicDevice::COMMAND_INC_ADDRESS, PicDevice::flags, PIC_HAS_OSCAL, Device::progress(), Device::progress_count, PicDevice::read_prog_data(), THROW_ERROR, and PicDevice::write_command().

Referenced by Pic16Device::read().

      unsigned int offset;

      try {
            for(offset=0; offset < this->codesize; offset++) {

                  if(verify) {
                        /* Don't verify the OSCAL location. */
                        if(! ((this->flags & PIC_HAS_OSCAL) &&
                          (offset == this->codesize-1))) {
                              if((uint32_t)buf[base+offset] != this->read_prog_data())
                                    throw runtime_error("");
                  } else {
                        buf[base+offset] = this->read_prog_data();
      } catch(std::exception& e) {
            THROW_ERROR(runtime_error, "%s at address 0x%04lx",
              verify ? "Verification failed" : "Couldn't read program memory",

Generated by  Doxygen 1.6.0   Back to index