Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic16Device::write_program_memory ( DataBuffer buf,
long  base = 0 
) [protected, virtual, inherited]

Program the entire contents of program memory to the PIC device.

Parameters:
buf A DataBuffer containing the data to program.
base The offset within the data buffer to start retrieving data. If this parameter isn't specified, it defaults to 0.
Precondition:
The PIC should have it's program counter set to the beginning of program memory.
Postcondition:
The program counter is pointing to the address immediatly after the last program memory address.
Exceptions:
runtime_error Contains a description of the error along with the address at which the error occurred.

Reimplemented in Pic16f87xADevice.

Definition at line 298 of file Pic16Device.cxx.

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

Referenced by Pic16Device::program().

                                                                 {
      unsigned int offset;

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

                  /* Skip but verify blank locations to save time */
                  if(buf.isblank(base+offset)) {
                        /* Don't verify the OSCAL location. */
                        if(! ((this->flags & PIC_HAS_OSCAL) &&
                          (offset == this->codesize-1))) {
                              if(read_prog_data() != (uint32_t)buf[base+offset])
                                    break;
                        }
                  } else {
                        if(!this->program_one_location((uint32_t)buf[base+offset]))
                              break;
                  }
                  this->write_command(COMMAND_INC_ADDRESS);
                  this->progress_count++;
            }
            if(offset < this->codesize) throw runtime_error("");
      } catch(std::exception& e) {
            THROW_ERROR(runtime_error,
              "Couldn't write program memory at address 0x%04lx", base+offset);
      }
}


Generated by  Doxygen 1.6.0   Back to index