Continue to Site

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.

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

Save information into EEPROM

Status
Not open for further replies.
hi,
I will write and post a short demo program for discussion.
 
Hi,
This is Oshonsoft Basic, the assembler listing from this file is attached.

Code:
AllDigital

Dim dta As Byte
Dim bfr As Byte

TRISA = 0xff  'inp
TRISB = 0x00  'out

main:

If PORTA.4 = 1 Then
Read 0, dta
PORTB = dta
Endif

scan:
'SwA on
If PORTA.0 = 1 Then
bfr.0 = 0
PORTB.0 = 1
Write 0, PORTB
Endif

'SwA off
If PORTA.1 = 1 Then
bfr.0 = 0
PORTB.0 = 0
Write 0, PORTB
Endif

'SwB on
If PORTA.2 = 1 Then
bfr.1 = 0
PORTB.1 = 1
Write 0, PORTB
Endif

'SwA off
If PORTA.3 = 1 Then
bfr.1 = 0
PORTB.1 = 0
Write 0, PORTB
Endif

Goto scan


The program covers just four switches connected to PORTA.
A0= ON, A1= OFF.. these control PORTB.0,,,, bit 0 in bfr
A2= ON, A3= OFF.. these control PORTB.1,,,, bit 1 in bfr

The state of the bfr is recalled if PORTA.4 switched ON at power up.

I hope you follow, it has been tested in a Simulator and it works.

Is this what you have in mind.?
 
Last edited:
Thanks.. It really help and i'm really appreciate it.

hi,
If thats the way you are considering the switch control, it would be a good idea to 'shorten' the code by making the 'write' to EEPROM a subroutine which is called when the switches are pressed.
In that code fragment I posted, the 'write' code block is repeated for every switch press, which is inefficient.

Do you follow.?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top