Save information into EEPROM

Status
Not open for further replies.
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…