Problem write to code space pic 18f452


Closed Thread
Results 1 to 6 of 6

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Problem write to code space pic 18f452

    With 18F, you must jump by 2 instead of 1... Not a bad Idea to use WORD instead of byte either... however here's a quick fix
    Code:
            For I = 0 To 14 step 2 ' Loop 8 times, once for each address $1800 to $1807
                    A = $1800 + I ' Increment Address
                    D =i/2' Change Data 0,1,2,3,4,5,6,7
                    Writecode A,D ' Send value in D to code space location A
                    Next I
    mainloop:
            For I = 0 To 14 step 2 ' Loop 8 times, once for each address $1800 to $1807
                    A = $1800 + I ' Increment Address
                    readcode A,D ' Send value in D to code space location A
                    HSEROUT [dec A, "=",dec D,13,10]
                    Next I
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: Problem write to code space pic 18f452

    And another variant
    Code:
            A = $1800
            hserout ["Writing...",13,10]
            For I = 0 To 7 step 2  
                    D.highbyte =i
                    d.lowbyte=d.highbyte+1
                    Writecode A,D 
                    HSEROUT [dec A, "=",dec D.highbyte, " ", dec d.lowbyte,13,10]
                    a=a+2
                    Next I
    mainloop:
            hserout ["reading...",13,10]
            For a = $1800 To $1807 step 2 
                    readcode A,D 
                    HSEROUT [dec A, "=",dec D.highbyte, " ", dec d.lowbyte,13,10]
                    Next
    Steve

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

Members who have read this thread : 0

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