Selamat datang di ForSa! Forum diskusi seputar sains, teknologi dan pendidikan Indonesia.

Welcome to Forum Sains Indonesia. Please login or sign up.

Maret 29, 2024, 01:02:37 PM

Login with username, password and session length

Topik Baru

Artikel Sains

Anggota
Stats
  • Total Tulisan: 139,653
  • Total Topik: 10,405
  • Online today: 191
  • Online ever: 1,582
  • (Desember 22, 2022, 06:39:12 AM)
Pengguna Online
Users: 0
Guests: 186
Total: 186

Aku Cinta ForSa

ForSa on FB ForSa on Twitter

[ask] eeprom 24c64???

Dimulai oleh a_die, Mei 24, 2013, 09:56:28 AM

« sebelumnya - berikutnya »

0 Anggota dan 1 Pengunjung sedang melihat topik ini.

a_die

gan mau tanya gmn akses eeprom 24c64 pke avr
ane buat programnya g bisa buat nyimpen data
misal kn saat terjadi penekanan tombol maka variabel a akan dtimbh 1 (a=a+1) setlah itu variabel a akan disimpan dlm eeprom
dan saat diabaca menggunakan variabel b yg ditmpilkn ke lcd
ni codingnya gan
mohon dikoreksi

$regfile = "m32def.dat"
$crystal = 11059200
$baud = 9600
$hwstack = 32
$swstack = 10
$framesize = 40


Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.2 , Rs = Portb.0
Config Lcd = 16 * 2
Cursor Off
Cls
Deflcdchar 1 , 32 , 27 , 31 , 31 , 31 , 14 , 4 , 32         ' replace ? with number (0-7)
Const 24c64w = &B1010_0001                                  'slave write address
Const 24c64r = &B1010_0000                                  'slave read address
Config Debounce = 30

Config Pinc.2 = Input
Config Pinc.3 = Input
Config Pinc.4 = Input
Config Pinc.5 = Input
Dim A As Byte , Alamat As Byte , C As Byte
Cls
Locate 1 , 1
Lcd Chr(1) ; "Program EEPROM" ; Chr(1)
Wait 1
Alamat = 0
Main:
Cls
Do
   Locate 1 , 1
   Lcd "tekan tombol kiri"
   Locate 2 , 1
   Lcd "untuk isi EEPROM"
   Debounce Pinc.2 , 0 , Tulis , Sub
   Debounce Pinc.3 , 0 , Baca , Sub
Loop

Tulis:
      Incr A
      I2cstart
      I2cwbyte 24c64w
      I2cwbyte Alamat
      I2cwbyte A
      I2cstop
      Waitms 10
      Incr Alamat
Return

Baca:
   Gosub 24c64
   Cls
   Do
   Locate 1 , 1
   Lcd "isi eeprom"
   Locate 2 , 1
   Lcd C
   If Pinc.4 = 0 Then
      Gosub Main
   End If
Loop



24c64:
   I2cstart
   I2cwbyte 24c64w
   I2cwbyte Alamat
   I2cstart
   I2cwbyte 24c64r
   I2crbyte C , Nack
   I2cstop
Return