CWRITE and 18F25K50


Go to last post By: towlerg
Today 14:18
Forum: Master Synchronous Serial Port (MSSP) module / 3-wire SPI / I2C / Master and Slave modes
Starter: CharlieBrown
Views: 1780
Replies: 15
Go to last post By: keytapper
Today 12:29
Forum: Proton Plus Compiler v3
Starter: towlerg
Views: 0
Replies: 4
Today 12:25
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 0
Today 12:21
Forum: PICKAT
Starter: davutnacikaya
Views: 0
Replies: 1
Today 09:40
Forum: The Lounge
Starter: Tim
Views: 0
Replies: 2
Yesterday 23:22
Forum: Projects discussion
Starter: creatv
Views: 0
Replies: 5
Go to last post By: charliecoultas
Yesterday 20:43
Forum: The Lounge
Starter: pic-ignorant
Views: 0
Replies: 4
Yesterday 20:26
Forum: Proton Plus Compiler v3
Starter: Frizie
Views: 0
Replies: 7
Yesterday 18:31
Forum: LCD module
Starter: charliecoultas
Views: 0
Replies: 40
+ Reply to Thread
Results 1 to 10 of 10

Thread: CWRITE and 18F25K5016 days old

  1. #1
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,270
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default CWRITE and 18F25K50

    Help please.

    Using V3.7.2.1

    The CWRITE page of the compiler manual states that data can be written anywhere in memory and gives some samples however I am finding that it is only possible to write a full 64 byte block. Using PicKit to read back the contents of memory shows that nothing is written for less than 64 bytes

    Is it something I missed? This is the test code I used

    Code:
    Device = 18F25K50
    Declare Xtal = 48
    
    Dead_Code_Remove = On  
    Optimiser_Level = 3
     
    
    Dim Address As Word
    Dim Pointer As Byte
    Dim Data_Array [64] As Byte
    Dim Data_Value  As Byte
    
    Symbol Led1 = LATB.0
    Symbol Led2 = LATB.1
        
    Start:
    OSCCON = 110000                      ' settings for 16MHz INTOSC
    
    Pointer = 0
    Address = $e00                          ' start address
    
    For Pointer = 0 To 63
        Data_Array[Pointer] = Pointer       ' load data array
    Next
    
    For  Pointer = 0 To 60  '<<<<<<<<<<<<<<<<<<<<<<<<  change this to 63 and it works
        Data_Value = Data_Array[Pointer]    ' get data value
        CWrite Address,[Data_Value]         ' write to memory
        Inc Address                         ' next address
    Next
    
    High Led2                               ' Done
    While 1 = 1 : Wend
    My RAM is failing

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Administrator John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,717
    Thumbs Up
    Received: 126
    Given: 33
    Total Downloaded
    3.99 GB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    From an 18F datasheet, not the one you're using.

    A read from program memory is executed on one byte
    at a time. A write to program memory is executed on
    blocks of 64 bytes at a time. Program memory is
    erased in blocks of 64 bytes at a time.

    I've often wondered about this when reading the manual. But there are plenty of posts in the forum about how to write to program memory and it always involve writing a page of 64 bytes. It's why I try to choose a device with EEDATA.
    Read the Block of 64 bytes into RAM, erase the block, change the byte you need, write back the 64 bytes.
    John
    Last edited by John Drew; 3rd September 2019 at 06:57. Reason: added a bit

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,652
    Thumbs Up
    Received: 73
    Given: 95
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    Hi,

    Cwrite needs 2 things to work properly

    1 The start address has to be on the right boundary address
    2 You have to write all X bytes or the final section of code to instigate the actual write is not run.

    In the pic there is a set of reg's that you write too, that holds the data to write to the block. It's like a bank of ram just for the job. Once Proton counts you having written to all the regs it will instigate the write.

    This method allows the code to incrementally load the section in a say a loop rather than having to write it all on one massive line of code.

    As John said if you want to write a smaller section, read in the whole 64 byte block, modify the data and write it all back.

    Tim
    Tim

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,431
    Thumbs Up
    Received: 104
    Given: 25
    Total Downloaded
    5.47 GB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    What I always was/am afraid of is the write address.

    How one would know where to write to a particular PIC address without messing with the code space? And is the same for using i.e. a 12F1572?
    Regards

    Joseph

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,270
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    What have I missed?

    The Proton manual gives the impression that you can write anything just about anywhere and by reading, modifying, writing back a 64 byte block it would be possible would it not?

    Yes Tim, I'm aware of everything you wrote but I am still messing around with your old USB BootLoader code.

    With the original WriteToProm routine the first 8 bytes of each 16 byte line in a 64 byte block are written to memory OK but the next 8 bytes are corrupted. I have proven that the data and address are correct before the actual write.

    Doing the write by building an array first then writing the array may not be the best way but it works OK at different address such as $E00 or $F00

    I will reduce the file size of the screen clip of the incorrect writ and post back later.
    Last edited by See_Mos; 3rd September 2019 at 15:41.
    My RAM is failing

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,270
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    Attachment 3738

    It attached as a file instead of a picture and can be seen easily.
    Last edited by See_Mos; 3rd September 2019 at 16:08.
    My RAM is failing

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    467
    Thumbs Up
    Received: 84
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    that you can write anything just about anywhere and by reading, modifying, writing back a 64 byte block it would be possible would it not?
    No, not in a single operation.

    The 64-byte block must be aligned to a write-block page boundary. You can't cross pages in a single write.
    Also, to (re)write a block it must first be erased, which erases all bytes in the current page.

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,270
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    Yes, I already worked that out.

    OK, so what would be the next location above or including 0C20 and I will give that a try.

    The test code is only 104 bytes excluding the offset and looking at Tim's it code should write two 64 byte blocks, or pages OK
    Last edited by See_Mos; 3rd September 2019 at 17:42.
    My RAM is failing

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    467
    Thumbs Up
    Received: 84
    Given: 0
    Total Downloaded
    330.54 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    64 bytes is 0x40, so the block that contains 0x0C20 is:
    (0x0C20/0x40)*0x40 = 0xC00 (to 0xC3F)

    The block after that is 0xC40 - 0xC7F

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,270
    Thumbs Up
    Received: 38
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default Re: CWRITE and 18F25K50

    That didn't really help as I was already using 0e00 or 0f00 for test purposes

    I still have to discover why using pointers corrupted the saved data but I now have a workaround and a working 25K50 boot loader, though it still needs some work.
    My RAM is failing

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. PoortC problem with 18F25K50
    By Hemsys in forum Absolute Beginners Section
    Replies: 6
    Last Post: 29th August 2017, 07:28
  2. Unable to get 18F25K50 and new USB stack working
    By See_Mos in forum USB Module
    Replies: 8
    Last Post: 2nd March 2017, 17:17
  3. Using the Cwrite Command.
    By Mellbreak in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 23rd October 2012, 14:31
  4. Cwrite! How To :(
    By SELCUK in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 18th June 2007, 11:06
  5. Cwrite
    By rockybooth in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 27th July 2006, 14:12

Members who have read this thread since 14th September 2019, 08:39 : 0

Actions :  (Set Date)  (Clear Date)

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