Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic18Device::read_config_memory ( DataBuffer buf,
unsigned long  addr,
unsigned long  len,
bool  verify 
) [protected, virtual]

Reads a portion of the PIC configuration memory. This is basically the same as read_memory except there is some masking of the data.

buf The DataBuffer to store the read data. On a verify, this data is compared with the data on the PIC.
addr The byte address in the PIC's memory to begin the read. Since the PIC's memory is byte-oriented and the DataBuffer is 16-bit word oriented, the offset into the DataBuffer will be 1/2 the PIC memory address.
len The number of 16-bit words to read into the DataBuffer.
verify Boolean flag which indicates a verify operation against buf.
The progress_count is incremented by the number of configuration words read/verified.
runtime_error Contains a description of the error along with the configuration word number where the error occurred.

Definition at line 381 of file Pic18Device.cxx.

References COMMAND_TABLE_READ_POSTINC, config_masks, Device::progress(), Device::progress_count, set_tblptr(), THROW_ERROR, and write_command_read_data().

Referenced by read(), and write_config_memory().

      unsigned int data, cword_num;
      unsigned long i;

      cword_num = 0;
      try {
            addr >>= 1;             /* Shift to word addresses */
            for(i=0; i<len; i++) {
                  /* Give byte addresses to progress() to match datasheet. */

                  /* Read memory a byte at a time (little endian format) */
                  cword_num = addr - (0x300000/2);
                  data = write_command_read_data(COMMAND_TABLE_READ_POSTINC);
                  data |= (write_command_read_data(COMMAND_TABLE_READ_POSTINC) << 8);
                  if(verify) {
                        if((data & this->config_masks[cword_num]) !=
                          (buf[addr] & this->config_masks[cword_num]))
                              throw runtime_error("");
                  } else {
                        buf[addr] = data;
      } catch(std::exception& e) {
            THROW_ERROR(runtime_error, "%s of configuration word #%u failed",
              verify ? "Verification" : "Read", cword_num);

Generated by  Doxygen 1.6.0   Back to index