Need help with write function


Results 1 to 11 of 11

Threaded View

  1. #9
    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

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