Menu

Bug in read code for new PIC18 devices (read18FKx)

Anonymous
2022-07-01
2022-07-01
  • Anonymous

    Anonymous - 2022-07-01

    There is a bug in the read code for the "new" PIC18F devices:

    progP18.c:1595:

    void Read18FKx(int dim,int dim2,int options)

    Here dim2 is the eeprom size in bytes.

    There are several bugs (I think) related to this.

    1) In the device table, for some devices there is a "1" for the dim2
    value, for example here:

    {"18F27Q43,18F47Q43,18F57Q43",
    PIC18,8.5,1,
    Read18FKx,{0x20000,1,0x10},0,
    Write18FKx, {0x20000,0x400,0x10,0,0,0},0}, //128K, 1k, --, LV

    The "1" for the read parameter should really be 0x400.

    2) when dim2==0, the read function is supposed to take the EEPROM size
    from the device config information stored in the PIC.

    This is done in line 1753:

    if(z<DIMBUF-2){
        sizeEE=(bufferI[z+1]<<8)+bufferI[z+2];
        PrintMessage1("EEPROM size: %d\r\n", sizeEE);
    }
    

    But then later down in the function, tests are made checking the value
    of dim2 (which is set to 0 for automatic detection).

    e.g. line 1899:

    //****************** read eeprom ********************
    if(dim2){                   //EEPROM
    

    Another thing that is not nice is that "Forcing config words" is printed
    even when no config words are specified.... But this has no functional
    consequence and is easily fixed.

     
  • Alberto Maccioni

    Actually the meaning of dim2 is:
    // dim2=if>0 use eeprom, size is automatic when reading DCI
    So it is pointless to specify a value, as it is anyways read from the DCI area.
    So the meaningful values are 0 and not 0 (I use 1).
    To be more precise the comment should be:
    // dim2=if>0 use eeprom, size is automatically determined by reading DCI
    "Forcing config words" is not in that source file; can you detail the occurrence a little bit?

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.