Write and read to memory of PIC18F14k50


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2016
    Posts
    33

    Default Write and read to memory of PIC18F14k50

    Hello all,

    I am trying to write and read from memory of PIC18F14k50.I have following code to write to memory location $500:
    Code:
    DEFINE OSC 24
     
    X var byte
    Y var word
    Value var byte
    
    
    
    mainloop:    
    Pause 4000      
    Y = $500 
    Value=2
                                                           
    erasecode Y                                   
    for X = 1 to 16                                 
    writecode Y, Value                         
    Y = Y + 1                                       
    next X
       
       Goto mainloop

    I am trying to read from same location and turn LED on if 2 is stored at address $500.

    Code:
    DEFINE OSC 24 
    
    TRISC.4 = 0
    LED VAR PORTC.4 
    X var byte
    Y var word
    Value var byte
    
    mainloop:
    
    readcode $500, Value 
       If Value = 2 Then 
          HIGH LED   
          goto  ledout
          Pause 50
       Else
          LOW LED    
          Pause 50
       Endif
       Goto mainloop

    However It doesn't turn on the LED.Any thoughts?

    Thanks

  2. #2
    Join Date
    Sep 2009
    Posts
    748


    Did you find this post helpful? Yes | No

    Default Re: Write and read to memory of PIC18F14k50

    You delete content of entire FLASH memory when you erase FLASH before programming PIC.
    Try this:
    Code:
    DEFINE OSC 24
     
    X var byte
    Y var word
    Value var byte
    
    Pause 4000      
    Y = $500 
    Value=2
                                                           
    erasecode Y                                   
    for X = 1 to 16                                 
    writecode Y, Value                         
    Y = Y + 1                                       
    next X
    
    Blink:
       readcode $500, Value
       If Value = 2 Then 
          Toggle LED    
          Pause 500
       Else
          LOW LED    
       Endif
       GOTO Blink

Similar Threads

  1. Write Onewire data toa I2C memory / read ASCI
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 16th November 2008, 19:19
  2. A help with Write/Read a I2C memory
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 28th March 2008, 13:53
  3. Write and Read from internal Memory
    By joseph Degorio in forum Serial
    Replies: 10
    Last Post: - 2nd December 2007, 11:03
  4. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  5. cannot read/write to 16F690 data memory after CPD_ON
    By awdsas in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd November 2006, 11:46

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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