1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

write string in eeprom?

Discussion in 'Oshonsoft' started by ese2709, Aug 8, 2012.

  1. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    hai,

    i want to know how to write a string into eeprom(pic16f877) using oshonsoft...

    can i someone show me the code
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Are you asking for help with the PIC's internal EEPROM or an external EEPROM.?

    Basic or Assembly language.?
     
  3. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    internal eeprom pic16f877... basic language...
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK

    Do you mean like this.? if not , post a sample of your string.
     
  6. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    something like : lcd will display "Type Your Name" then user will type name using keypad. then the name will be save into eeprom. and can be read to display in lcd.

    i hope u will understand;)
     
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi.
    What you have to do is to create a character buffer and load the buffer with each character as its typed in.

    When the user types in the ENTER key the contents of the buffer will be written to EEPROM.

    Do you follow OK, if not I will post a demo later.
     
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Hi,
    This is one option.
    Code (text):
    'demo
    Dim pntr As Byte 'index pointer
    Dim chr(6) As Byte  '' keyboard entry buffer [array]
    Dim mem As Byte 'address location in eeprom


    'you should arrange so as that each character is typed in, it loads the chr ARRAY buffer
    'Test the character for CR code 0x13, then transfer to the EEPROM

    'simulated user typed input.
    chr(1) = "T"
    chr(2) = "E"
    chr(3) = "X"
    chr(4) = "T"
    chr(5) = 0x13

    mem = 0x00' memory address start
    For pntr = 1 To 5
    Write mem, chr(pntr)
    mem = mem + 1
    Next pntr

    End                                              
     
    Last edited: Aug 9, 2012
  9. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    tq... there is something i can see... let me try first... then i will show some result here....
     
  10. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    continue for my program: i have test the code and it successfull... then how can i show it on lcd?

    one more... i`m using keypad to insert the text... but i want to know how to check button is release or not after pressing button??

    TQ :p
     
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Please post the code you have written so that we can check for you.;)

    We also need to know details of your circuit diagram for the LCD connections to the PIC.
     
    Last edited: Aug 12, 2012
  12. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    Code (text):


    Define CONF_WORD = 0x3f72
    Define CLOCK_FREQUENCY = 12
    AllDigital

    Define LCD_BITS = 4
    Define LCD_DREG = PORTB
    Define LCD_DBIT = 0
    Define LCD_RSREG = PORTE
    Define LCD_RSBIT = 0
    Define LCD_RWREG = PORTE
    Define LCD_RWBIT = 1
    Define LCD_EREG = PORTE
    Define LCD_EBIT = 2
    Define LCD_READ_BUSY_FLAG = 1

    'For Keypad
    Symbol raw1 = RD7
    Symbol raw2 = RD6
    Symbol raw3 = RD5
    Symbol raw4 = RD4
    Symbol col1 = RD0
    Symbol col2 = RD1
    Symbol col3 = RD2
    Symbol col4 = RD3
    TRISD = 0xf0
    TRISB = 0
    Lcdinit

    Dim button As Byte
    Dim digit As Byte
    Dim pass As Byte
    Dim error As Bit
    Dim mem As Byte

    start:

    Lcdcmdout LcdClear

    Lcdout "ALARM SYSTEM"
    Lcdcmdout LcdClear
    Lcdout "New Password:"
    Lcdcmdout LcdLine2Home
    Lcdout "----"

    For digit = 1 To 4  '4 digit password
    Gosub get_button
    pass(digit) = button
    Lcdcmdout LcdLine2Pos(digit)  'replace '-' with key type
    Lcdout #button
    button = 0
    Next digit

    'go to write input data
    Gosub write_data

    Lcdcmdout LcdClear
    Lcdout "Password Saved"

    WaitUs 2000

    'Test Password
    Gosub check_password

    Goto start
    End                                              

    check_password:

    Lcdcmdout LcdClear
    Lcdcmdout LcdLine1Home
    Lcdout "Type Password"

    For digit = 1 To 4  '4 digit password
    Gosub get_button
    pass(digit) = button
    Lcdcmdout LcdLine2Pos(digit)
    Lcdout #button
    button = 0
    Next digit

    '???? Here how to check the input password is same with saved password, error = 1 if wrong password.... some code for me?

    If error = 1 Then
    Lcdout "Access Denied"
    WaitUs 2000
    Goto check_password
    Else
    Lcdout "Access verified"
    Endif
    Return                                            

    write_data:
    mem = 0x00  'memory address start
    For digit = 1 To 4
    Write mem, pass(digit)
    mem = mem + 1
    Next digit
    Return                                            

    get_button:

    While button = 0
    button = 0
    col1 = 1
    If raw1 = 1 Then button = 1
    If raw2 = 1 Then button = 5
    If raw3 = 1 Then button = 9
    If raw4 = 1 Then button = 13
    col1 = 0
    col2 = 1
    If raw1 = 1 Then button = 2
    If raw2 = 1 Then button = 6
    If raw3 = 1 Then button = 10
    If raw4 = 1 Then button = 14
    col2 = 0
    col3 = 1
    If raw1 = 1 Then button = 3
    If raw2 = 1 Then button = 7
    If raw3 = 1 Then button = 11
    If raw4 = 1 Then button = 15
    col3 = 0
    col4 = 1
    If raw1 = 1 Then button = 4
    If raw2 = 1 Then button = 8
    If raw3 = 1 Then button = 12
    If raw4 = 1 Then button = 16
    col4 = 0
    Wend

    '?????here the code wait for button release before return.... some code for me??? :)
    Return                                            


     
    there is some code from my program... not finish yet... need some help from you all... thank you :eek:
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi ese,
    I will give it a run thru today.;)
    Post later as an Edit.
    E.
     
  14. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    Tq very Much... :)
     
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    This small change works for the key release.


    Code (text):
    col4 = 1
    If raw1 = 1 Then button = 4
    If raw2 = 1 Then button = 8
    If raw3 = 1 Then button = 12
    If raw4 = 1 Then button = 16
    col4 = 0
    Wend

    While PORTD <> 0
    Wend



    '?????here the code wait for button release before return.... some code for me??? :)
    Return
     
    Last edited: Aug 13, 2012
  16. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    Code (text):
    col4 = 1
    If raw1 = 1 Then button = 4
    If raw2 = 1 Then button = 8
    If raw3 = 1 Then button = 12
    If raw4 = 1 Then button = 16
    col4 = 0
    Wend

    While PORTD <> 0
    Wend



    '?????here the code wait for button release before return.... some code for me??? :)
    Return
    Not working for key release :confused:
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    It works for me in OSH simulation.

    You need to mask off some of PORTD bits. You have not shown me how the keypad is connected to PORTD.
     
  18. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    next post
     
    Last edited: Aug 13, 2012
  19. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0
    View attachment 66345

    this is the keypad connection... it is like your keypad???

    last post is wrong... this one is tru... hehehe
     
    Last edited: Aug 13, 2012
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,233
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    You are reading PORTD.7,6,5,4 and writing to PORTD 3,2,1,0 [columns]

    So which half of PORTD should you mask OFF.??
    before testing for '0':rolleyes:


    While PORTD <> 0
    Wend
     
  21. ese2709

    ese2709 New Member

    Joined:
    Aug 20, 2011
    Messages:
    30
    Likes:
    0

    i think portd.7 6 5 4... it on row... i hope true... how i can make it mask off??
     

Share This Page