Announcement

Collapse
No announcement yet.

user ID location read in 18f67K22

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • user ID location read in 18f67K22

    Hi darrel ,

    i am porting code from 16f1947 to 18f67k22

    the section where the serial number bytes are writen via the melabs programer to user id 8000 -8003h and the commands are needed to read them need to be charged to work on the 18F67k22

    the 18f67k22 assigned locations 200000h-2000007h for ID locations ,
    but i am bit lost on how the config words protection and the TBRD command would work on the extended address location

    can advise on the code
    regards

    sheldon
    existing code for 16f1947 is

    Code:
     EE_ADR       VAR WORD EXT : @EE_ADR = EEADRL  ' Address byte In PIC config using EXT location address
     GateID       VAR BYTE[4]                      ' User ID bytes at location $8000 - $8003 - stored serial number
    
     FOR EE_ADR = $8000 TO $8003   ' Read User ID bytes $8000 - $8003 from Programed Mlabs serial Number option
            EECON1.6 = 1   ; CFGS    ' Set Bit so can read config space
            EECON1.0 = 1   ; RD      ' set the read config bit
    @ NOP                    ' A read from Flash memory requires NOP's after the RD bit
    @ NOP                    ' 2nd NOP is required when doing a read
            GateID(EE_ADR - $8000) = EEDATL
        NEXT EE_ADR
    
        write $0A,GateID[3]    ' Serial Number MSB
        write $0B,GateID[2]    ' Serial Number
        write $0C,GateID[1]    ' Serial Number
        write $0D,GateID[0]    ' Serial Number LSB

  • #2
    Well, if I understood correctly ... I think the question was ...
    How do I read the first 4 bytes of the 8 available user ID locations on an 18F?

    Code:
    ID    VAR BYTE[4]
    
    ASM
        movlw    upper(_IDLOC0)
        movwf    TBLPTRU
        movlw    high(_IDLOC0)
        movwf    TBLPTRH
        movlw    low(_IDLOC0)
        movwf    TBLPTRL
        TBLRD*+
        movff    TABLAT, _ID
        TBLRD*+
        movff    TABLAT, _ID + 1
        TBLRD*+
        movff    TABLAT, _ID + 2
        TBLRD*
        movff    TABLAT, _ID + 3
    ENDASM
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

    Comment


    • #3
      with the asm commands shown find the correct locations of 200000h - 200007h, ?

      Comment


      • #4
        Why would it not?
        PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
        Never download a PIC datasheet from anywhere but microchip.com

        Comment


        • #5
          there is nothing in the commands that state the location address for the id , unlike the other code.

          my asm is not good as yet but i am getting there

          the " _IDLOC0" command in it self must point to sets the location of 200000h- 200007h ???

          but i cant find " _IDLOC0" command in the data sheet

          i try and comment the asm , of what i follow

          Code:
          ASM
                                                          ; get 22bit address into TBLPTR register 
              movlw    upper(_IDLOC0)           ; get upper byte of ID(20) - location 200000h ?
              movwf    TBLPTRU                    ; move the location address into upper table 
              movlw    high(_IDLOC0)             ; get high byte of ID(00) - location 200000h ?
              movwf    TBLPTRH                    ; move the location address into High table
              movlw    low(_IDLOC0)              ; get low byte of ID(00) - location 200000h ?
              movwf    TBLPTRL                    ; move the location address into low table  
             
           TBLRD*+  ; get data into TABLAT reg with address in TBLPTR reg,increment TBLPTR reg after read
              movff    TABLAT, _ID                 ; get data from into _ID(0) variable
              TBLRD*+                                 ; get data into TABLAT reg , increment after read   
              movff    TABLAT, _ID + 1            ; get data from into _ID(1) variable
              TBLRD*+                                  ; get data into TABLAT reg , increment after read 
              movff    TABLAT, _ID + 2            ; get data from into _ID(2) variable
              TBLRD*                                   ; get data into TABLAT reg , increment after read 
              movff    TABLAT, _ID + 3            ; get data from into _ID(3) variable
          ENDASM

          Comment


          • #6
            well the code compiles ok , so to test i setup the serial number on the melabs programmer

            but it seems that the chip wont take the serial number at 200000h , although the programmer say it expected user id should be the serial number programed ,

            there is no protection on any blocks to stop the writing of the serial number any suggestions

            cheers
            sheldon

            Comment


            • #7
              Hi darrel ,

              the melab serial number option writes a byte per location , however the 18f67k22 has a word per location , as a result the asm need to increment 2 times to point to the next byte of serial number in the asm

              I am still lost on where " _IDLOC0 " command is listed in the data sheet that allow to point to the User ID value , but it works

              regards

              sheldon

              Code:
              ASM
                                                    ; get 22bit address into TBLPTR register 
                  movlw    upper(_IDLOC0)           ; get upper byte of IDLOC0(20) - location 200000h 
                  movwf    TBLPTRU                  ; move the location address into upper table 
                  movlw    high(_IDLOC0)            ; get high byte of ID(00) - location 200000h 
                  movwf    TBLPTRH                  ; move the location address into High table
                  movlw    low(_IDLOC0)             ; get low byte of ID(00) - location 200000h 
                  movwf    TBLPTRL                  ; move the location address into low table  
                  TBLRD*+                           ; get data into TABLAT reg with address in TBLPTR reg,increment TBLPTR reg after read
                  movff    TABLAT, _GateID          ; get LSB of serial ,lower word byte data from into _ID(0) variable
                  TBLRD*+                           ; get upper word byte data into TABLAT reg , increment after read   
                  TBLRD*+                           ; get serial data into TABLAT reg , increment after read   
                  movff    TABLAT, _GateID + 1      ; get lower word byte data from into _ID(1) variable
                  TBLRD*+                           ; get upper word byte data into TABLAT reg , increment after read 
                  TBLRD*+                           ; get lower word byte data into TABLAT reg , increment after read   
                  movff    TABLAT, _GateID + 2      ; get data from into _ID(2) variable
                  TBLRD*+                           ; get upper word byte data into TABLAT reg , increment after read 
                  TBLRD*+                           ; get MSB of serial , lower word byte data into TABLAT reg , increment after read   
                  movff    TABLAT, _GateID + 3      ; get data from into _ID(3) variable
              ENDASM   
              
                  write $0A,GateID[3]    ' Serial Number MSB
                  write $0B,GateID[2]    ' Serial Number
                  write $0C,GateID[1]    ' Serial Number
                  write $0D,GateID[0]    ' Serial Number LSB

              Comment


              • #8
                Addresses for everything related to individual PICs are defined in the P*.inc files in the MPASM Suite folder.

                c:\Program Files\Microchip\MPASM Suite - 32-bit systems
                c:\Program Files (x86)\Microchip\MPASM Suite - 64-bit systems

                Originally posted by P18F67K22.inc
                ;----- IDLOC Equates --------------------------------------------------
                _IDLOC0 EQU H'200000'
                _IDLOC1 EQU H'200001'
                _IDLOC2 EQU H'200002'
                _IDLOC3 EQU H'200003'
                _IDLOC4 EQU H'200004'
                _IDLOC5 EQU H'200005'
                _IDLOC6 EQU H'200006'
                _IDLOC7 EQU H'200007'
                And you're right!
                It would be nice to be able write them as bytes.

                Nice fix.
                PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
                Never download a PIC datasheet from anywhere but microchip.com

                Comment


                • #9
                  thanks darrel ,
                  ill start reading more of the inc file details for better reference understanding

                  the user id is still giving me a pain , as it seems i can only program it write it once ,
                  an erase will not clear it ( yep i checked the option do erase the user iD ) something strange still going on with these 18f67k22 that i not worked out

                  tryng now to get the adc working on the chip , if you have some sample of using an4 for this chip for ref please post a bit for review , mainly register and tad / clock selection using ar 32osc ,

                  i am just reviewing all adc registers - again

                  cheers

                  Sheldon

                  Comment


                  • #10
                    Originally posted by longpole001 View Post
                    as it seems i can only program it write it once ,
                    an erase will not clear it
                    Confirmed!

                    The USER ID area is not getting erased, no matter what options are set.

                    I've put in a request to have it looked at.
                    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
                    Never download a PIC datasheet from anywhere but microchip.com

                    Comment


                    • #11
                      Can u advise on the chip id u checked it with[COD[/CODE]

                      Comment


                      • #12
                        The issue is not related to the silicon revision.

                        But the device ID of my chip reads 5184, which means it's rev B1.
                        PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
                        Never download a PIC datasheet from anywhere but microchip.com

                        Comment

                        Working...
                        X