How to read ID locations of PIC 18F4550??


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default How to read ID locations of PIC 18F4550??

    My application is using a PIC 18F4550, for which the data sheet says:
    “25.6 ID Locations
    Eight memory locations (200000h-200007h) are
    designated as ID locations, where the user can store
    checksum or other code identification numbers. These
    locations are both readable and writable during normal
    execution through the TBLRD and TBLWT instructions
    or during program/verify. The ID locations can be read
    when the device is code-protected.”

    I have been trying to figure out the code for reading the contents of these 8 memory locations so that I can transmit them via BufferOut over USB interface.

    Following doesn’t seem to work:
    For i = 0 to 8
    READ 2097152+I, ID1 ‘Where 2097152d = $200000 as starting address location for ID locations
    Next

    Can anyone please advise me how this should be coded in PICBASICPro 2.6?

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    why not just use the TBLRD and TBLWT instructions?

    for example: (note: untested)

    Code:
    VAR i BYTE
    VAR ID BYTE[8]
    
    TBLPTRU=$20 ' Address $200000
    TBLPTRH=$00
    TBLPTRL=$00
    
    FOR i=0 TO 7
    @TBLRD*+  ; Get value and increment the address
    ID[i]=TABLAT  ' Store the ID
    NEXT i
    *edit* changed so it saves all 8 IDs
    Last edited by Kamikaze47; - 10th January 2010 at 07:29.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default It Works! Consider it now tested.

    Quote Originally Posted by Kamikaze47 View Post
    for example: (note: untested)
    Thanks so much, Kamikaze47. It works as you wrote it. So you can consider it as tested by virtue of it working in my application.

    One caution to any future readers of this thread: Make sure you know whether the ID Locations for your target chip are left or right justified. I am using the PicFlash programmer from mikroElectronika to burn programs to my target 18F4550 because it permits you to edit the ID Locations at burn time. In the case of the 18F4550 the ID Locations are left justified (ID(0) at left ID(7) at far right) as they appear in the window screen on PicFlash. I spent a lot of time discovering this while my code was using ID(7) when I thought I was using ID(0). Just a warning to possibly save you some the time I had to waste. Check your programmer on whether left or right justified!

Similar Threads

  1. Q: using MCLR for Input on 12F683
    By picster in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 31st January 2009, 15:25
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. Replies: 16
    Last Post: - 3rd November 2008, 19:58
  4. Can a PIC PIC a PIC?
    By afbecker in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd January 2008, 19:55
  5. Write and Read from eeprom
    By savnik in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 9th June 2007, 14:56

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts