Help with writecode needed


Closed Thread
Results 1 to 5 of 5
  1. #1
    Marten's Avatar
    Marten Guest

    Question Help with writecode needed

    Hi

    I have been trying to use writecode on my 18F252 for a while, but i seem to fail whatever i do

    I need a simple code example to get me going, i have looked at Melanies posts about the subject, but i need more concrete advice.

    I'm trying to copy the contents from one adress in codespace to another.

    if someone could write a few lines and show me how it's supposed to be done, with readcode,erasecode,eecon and all, please ?

    use $FE0 --> $FF0 or something.

    I have PicBasic Pro 2.42,have not used PBP for long, i 'm migrating from AtomBasic > PBP, so far so good, but my adventures with writecode makes my head spin.

    Marten

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    probably you'll need an update. Here's a quote from Melabs Website
    When using WRITECODE to store data in the code space of these parts, you have to use a block-write method. This different than some of the other self-programming devices like the 16F87x, which will allow you to write a single location. Refer to the Microchip datasheet for more information.

    The 18F parts have recently been introduced by Microchip. As with all new technology, they are not perfect. We have corrected for all the anomalies that we can in our development tools, but there is a chance that you may find a problem that affects your application. It's a good idea to check the Microchip website for current posting of errata concerning these parts
    At this link
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Marten's Avatar
    Marten Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks, i have spent some time in the datasheet for the 252, done some "Rtfm" and tried to figure it out, but i still don't get it right, could you give me some sample code ?


    In my world i thought that you could do a read and a' write
    like

    read $FF0,variable
    write $FF0,variable

    I have used read and write before, stored data in eeprom and so on, but i seem to stupid when it comes to doing byte-write stuff, please help ...





    Marten

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i'm confused, do you want to read/write from CODESPACE or EEPROM

    READ/WRITE = Internal EEPROM
    READCODE WRITECODE = code space

    i'm not a fan of Writecode and readcode, but i think you must use a WORD sized variable to do that on those 18Fs series
    Last edited by mister_e; - 27th February 2005 at 23:11.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Marten's Avatar
    Marten Guest


    Did you find this post helpful? Yes | No

    Unhappy

    Sorry for the confusion !

    What i mean, what i am trying to do, is to copy parts of code from one adress in codespace to another, in the same way that you use read and write with eeprom, i'm going to use this function to update code in a 18F252 from an smartcard later on, i simply have to learn how it all works first.

    what i have tried to do is the following:

    'Lcd Defines removed from code snip'

    define osc 20

    snip1 var word
    snip2 var word


    erasecode $7FF

    readcode $000,snip1
    pause 50
    writecode $7FF,snip1
    pause 50
    readcode $7FF,snip2

    LCDOUT $FE,1,"Orig: ",hex snip1
    LCDOUT $FE,$C0, "Copy: ",hex snip2


    This, does not work, snip1 and 2 does not have the same value,and it is many things that may be wrong, and i do not know what at the moment, the data sheet says that i must perform a block write with 8 bytes, something i dont understand how, without a array variable 'str var\8' or something like it, that is whats bugging me .

    Could you or anyone tell me how to proceed, is there any configuration bit that i cant see ?, i have checked all the bits in 18F252.inc and P18F252 and everything that sounds like write protection is disabled.


    Marten
    Last edited by Marten; - 28th February 2005 at 00:13. Reason: Error

Similar Threads

  1. Bootloader For 18F4520
    By isaac in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 24th March 2010, 17:56
  2. WRITECODE, ERASECODE, and interrupts
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th March 2010, 02:46
  3. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  4. Can anyone help me to use Writecode for pic18f458 ?
    By dip1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th June 2006, 22:29

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