• 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.

write string in eeprom?

Status
Not open for further replies.

ese2709

New Member
hai,

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

can i someone show me the code
 

ericgibbs

Well-Known Member
Most Helpful Member
hai,

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

can i someone show me the code
hi,
Are you asking for help with the PIC's internal EEPROM or an external EEPROM.?

Basic or Assembly language.?
 

ese2709

New Member
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;)
 

ericgibbs

Well-Known Member
Most Helpful Member
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;)
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.
 

ericgibbs

Well-Known Member
Most Helpful Member
Hi,
This is one option.
Code:
'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:

ese2709

New Member
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
 

ericgibbs

Well-Known Member
Most Helpful Member
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
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:

ese2709

New Member
Code:
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:
 

ericgibbs

Well-Known Member
Most Helpful Member
hi ese,
I will give it a run thru today.;)
Post later as an Edit.
E.
 

ericgibbs

Well-Known Member
Most Helpful Member
Tq very Much... :)
hi,
This small change works for the key release.


Code:
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:

ese2709

New Member
Code:
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:
 

ericgibbs

Well-Known Member
Most Helpful Member
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.
 

ericgibbs

Well-Known Member
Most Helpful Member
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
 

ese2709

New Member
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

i think portd.7 6 5 4... it on row... i hope true... how i can make it mask off??
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top