Need help with write function


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Wink Feeling as an apprentice among these guys (and girls) allow me to add the followings

    Hi Chris,
    EEPROM is already a reserved word.
    So in your code, you should be using a different name for EEPROM subroutine, say WriteRom.


    Code:
    EEPROM 0,[0,0]  
    'This will write 0 to EEPROM location 0 
    'and 0 to EEPROM location 1.
    'works only during the programming of PIC
    'Not each time PIC powers up
                                                                                                     
    Beep var byte
    Flash var byte
    
    
    Gosub readrom   
    'Since EEPROM locations 0 and 1 have known values now,
    'we can read and store them.
    'This will be done each time PIC powers up.
    'So each time PIC powers up we will get the last saved values.
    
    Start:
    
    if portb.4=1 then
      beep=beep+1
      gosub WriteRom      'We Write the new value into EEPROM.
      gosub ReadRom       'Then we read it right away and store it.
      if beep=1 then high portb.0
    endif
    
    if portb.3=1 then 
       flash=flash+1
       gosub WriteRom      'We Write the new value into EEPROM.
       gosub ReadRom       'Then we read it right away and store it.
       if flash=2 then high portb.1
    endif
    
    goto start
    
    
    WriteRom:
        write 0, beep   'Takes approx. 10mSec to complete.
        pause 15
        write 1, flash
        pause 15
        return
    
    ReadRom:
        read 0, beep   'Reading is almost instantenous
        read 1, flash
        return
    
    end

    - In your code, when will you "low" the ports after you pull them high?
    - Pulling the ports high is(are) inside the IF statements; are not they supposed to be outside the IF statements but inside the main loop?



    -----------------------------------------------
    Last edited by sayzer; - 3rd June 2006 at 10:03.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie, Paul, Sayzer and Arch. I have been successful in writing and reading a 16F688. Just one question in response to the post by Sayzer. I used the data command, write command and read command. I see Sayzer used the EEPROM to store the variables and when looking at the PBP manual, I don't understand what the difference is. Just by using Data to program, read to view and write to store, everything worked great. What's the difference between Data and EEPROM and why would someone choose EEPROM over Data?

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


    Did you find this post helpful? Yes | No

    Default

    Unless you want to use the 'label' feature as stated in the DATA section, there's no difference as same program the internal EEPROM at programming time.

    The main difference is just in the way to write the statement.

    I feel that one or the other is an BASICStamp statement...

    Now i don't know why but i always use the DATA statement... or MPASM assembler DE
    Steve

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

Similar Threads

  1. WRITE: One more PBP 2.60 Surprise ...
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 26th August 2009, 09:10
  2. Replies: 5
    Last Post: - 29th May 2008, 18:03
  3. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Storing Strings using the Write command
    By BobP in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2005, 11:31

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