Üdv! Nem tudja valaki, ezt az eeprom-ot miképp lehetne égetni?
STK200 tuti nem jó. Esetleg ha van valakinek rajz, megköszönném.
ATMEL 24c08
'**********************************************************************
' Application Note: 16 Bit Addressing on the I2C Bus.
' (8 bit data transfers one byte at a time)
'-----------------------------------------------------
'
' Program-ID.: I2C_EEPROM.bas.
' Date...... : 04 / 04 / 2002
' Description: Example program for I2c EEprom write and read routines
'
' Author : Victoria Welch (vikki@oz.net).
' This program finally helped me get my 24LC64 EEPROM working.
' Many thanks Brent! I Converted the original program into an
' application note in the hope it helps others new to these devices.
'
' Brent Nelson (spock50@gte.net).
' Brent provided the orginal form of this program to the BASCOM list.
'
' Remarks:
' Setup for the AT90S2313 using portb.0 for SDA and Portb.1 for SCL.
'
' Uses onboard serial port.
'
' This program provides an example for writing to and reading from
' an I2C EEPROM device wired for device 0 (AO,A1 and A2 all pulled
' to Gnd).
'
' This has been tested with a Microchip 24LC65.
'
'**********************************************************************
$regfile = "ATtiny2313.dat"
$crystal = 7372800
$baud = 9600
'$sim
'**********************************************************************
'** Set up Data Direction Registers and ports - Do this before defining I2C pins!
'** Read up on this in the data sheet, understanding is important!
'**********************************************************************
' Port D
Portd = &B0000_0000
Ddrd = &B1111_1100
'**********************************************************************
'** Define and initialize I2C pins **
'**********************************************************************
Config Pind.2 = Input
Portd.2 = 1 'Int0
Config Int0 = Falling
Config Sda = Portd.5 ' I2C Data.
Config Scl = Portd.4 ' I2C Clock.
'**********************************************************************
'** Declate subroutines **
'**********************************************************************
'
' This subroutine reads data from the I2C EEPROM.
'
Declare Sub I2c_ram_read(address_desired As Word)
Declare Sub I2c_ram_write(address_desired As Word , Content As Byte)
'**********************************************************************
'** Define working variables and constants **
'**********************************************************************
Dim I2c_eeprom_address_desired As Word
Dim I2c_eeprom_address_high_byte As Byte
Dim I2c_eeprom_address_low_byte As Byte
Dim Data_work_var As Byte
Dim Szamlalo As Word
Dim Tom As Byte
Dim K As Byte
Dim A As Byte
Dim Quit As Byte
' Change the 3 "AD" bits to reflect the I2C address of the device
' (corresponding to A0,A1 and A2)..
' FAM AD M
Const Eeprom_chip_write_command = &B10100000 ' Family "A", Device/unit 1, write.
Const Eeprom_chip_read_command = &B10100001 ' Family "A", Device/unit 1, Read.
'**********************************************************************
'** Actual work starts here. **
'**********************************************************************
Main:
Enable Interrupts
Enable Int0
On Int0 Stopbutton
Print "I2C EEPROM Test Program."
Prog0:
Do
Inputhex "|d|ump 1x16, |l|ap 16x16, |b|ytewrite = " , A
Select Case A
Case 13 : Goto Prog1 'd dump 16-byte
Case 11 : Gosub Prog2 'b byte írás
Case 21 : Goto Prog4 'l lap 16x16 byte
End Select
Loop
Prog1:
Szamlalo = 1023
Inputhex "dump 1x16byte address = " , I2c_eeprom_address_desired
Do
Print Hex(i2c_eeprom_address_desired) ; " " ;
For Tom = 0 To 15
Call I2c_ram_read(i2c_eeprom_address_desired)
Print ; Hex(data_work_var) ; ;
Incr I2c_eeprom_address_desired
Decr Szamlalo
Next
Print " tovabb|ent| out|esc|"
K = Waitkey()
If K = 27 Then Goto Prog0
Loop Until Szamlalo = 0
Prog4:
Szamlalo = 256
Inputhex "dump 16x16 byte address = " , I2c_eeprom_address_desired
Do
Print Hex(i2c_eeprom_address_desired) ; " " ;
For Tom = 0 To 15
Call I2c_ram_read(i2c_eeprom_address_desired)
Print ; Hex(data_work_var) ; ;
Incr I2c_eeprom_address_desired
Decr Szamlalo
Next
Print ""
Loop Until Szamlalo = 0
Goto Prog0
End
'**********************************************************************
'** Define Subroutines **
'**********************************************************************
Sub I2c_ram_read(address_desired As Word)
I2c_eeprom_address_low_byte = Low(address_desired)
I2c_eeprom_address_high_byte = High(address_desired)
I2cstart
I2cwbyte Eeprom_chip_write_command
I2cwbyte I2c_eeprom_address_high_byte
I2cwbyte I2c_eeprom_address_low_byte
I2cstart
I2cwbyte Eeprom_chip_read_command
I2crbyte Data_work_var , Nack
If Err = 0 Then
Print " " ;
Else
Print "Read failed: " ;
End If
I2cstop
Waitms 10
End Sub
Prog2:
Inputhex "bytewrite address = " , I2c_eeprom_address_desired
Prog3:
Call I2c_ram_read(i2c_eeprom_address_desired)
Print Hex(i2c_eeprom_address_desired) ; " " ; Hex(data_work_var);
Inputhex " = " , Data_work_var
Call I2c_ram_write(i2c_eeprom_address_desired , Data_work_var) ' Write it to the EEPROM.
Incr I2c_eeprom_address_desired
Inputhex , Quit
If Quit = &H1A Then Goto Prog0
Goto Prog3
Return
'**********************************************************************
'** Define Subroutines **
'**********************************************************************
Sub I2c_ram_write(address_desired As Word , Content As Byte)
I2c_eeprom_address_low_byte = Low(address_desired)
I2c_eeprom_address_high_byte = High(address_desired)
I2cstart
I2cwbyte Eeprom_chip_write_command
I2cwbyte I2c_eeprom_address_high_byte
I2cwbyte I2c_eeprom_address_low_byte
I2cwbyte Content
If Err = 0 Then
Print "Write is good: Location: " ; Hex(address_desired) ; "=" ; Hex(data_work_var);
Print " the next |enter|, out |q|"
Else
Print "Write failed: Location: " ; Address_desired
End If
I2cstop
Waitms 50
End Sub
Stopbutton:
Wait 10
Return
Ezzel a progival lehet az attiny2313 board v11. panelon az eeprom-ot olvasni illetve byte-onként irni.
Jtama
' Application Note: 16 Bit Addressing on the I2C Bus.
' (8 bit data transfers one byte at a time)
'-----------------------------------------------------
'
' Program-ID.: I2C_EEPROM.bas.
' Date...... : 04 / 04 / 2002
' Description: Example program for I2c EEprom write and read routines
'
' Author : Victoria Welch (vikki@oz.net).
' This program finally helped me get my 24LC64 EEPROM working.
' Many thanks Brent! I Converted the original program into an
' application note in the hope it helps others new to these devices.
'
' Brent Nelson (spock50@gte.net).
' Brent provided the orginal form of this program to the BASCOM list.
'
' Remarks:
' Setup for the AT90S2313 using portb.0 for SDA and Portb.1 for SCL.
'
' Uses onboard serial port.
'
' This program provides an example for writing to and reading from
' an I2C EEPROM device wired for device 0 (AO,A1 and A2 all pulled
' to Gnd).
'
' This has been tested with a Microchip 24LC65.
'
'**********************************************************************
$regfile = "ATtiny2313.dat"
$crystal = 7372800
$baud = 9600
'$sim
'**********************************************************************
'** Set up Data Direction Registers and ports - Do this before defining I2C pins!
'** Read up on this in the data sheet, understanding is important!
'**********************************************************************
' Port D
Portd = &B0000_0000
Ddrd = &B1111_1100
'**********************************************************************
'** Define and initialize I2C pins **
'**********************************************************************
Config Pind.2 = Input
Portd.2 = 1 'Int0
Config Int0 = Falling
Config Sda = Portd.5 ' I2C Data.
Config Scl = Portd.4 ' I2C Clock.
'**********************************************************************
'** Declate subroutines **
'**********************************************************************
'
' This subroutine reads data from the I2C EEPROM.
'
Declare Sub I2c_ram_read(address_desired As Word)
Declare Sub I2c_ram_write(address_desired As Word , Content As Byte)
'**********************************************************************
'** Define working variables and constants **
'**********************************************************************
Dim I2c_eeprom_address_desired As Word
Dim I2c_eeprom_address_high_byte As Byte
Dim I2c_eeprom_address_low_byte As Byte
Dim Data_work_var As Byte
Dim Szamlalo As Word
Dim Tom As Byte
Dim K As Byte
Dim A As Byte
Dim Quit As Byte
' Change the 3 "AD" bits to reflect the I2C address of the device
' (corresponding to A0,A1 and A2)..
' FAM AD M
Const Eeprom_chip_write_command = &B10100000 ' Family "A", Device/unit 1, write.
Const Eeprom_chip_read_command = &B10100001 ' Family "A", Device/unit 1, Read.
'**********************************************************************
'** Actual work starts here. **
'**********************************************************************
Main:
Enable Interrupts
Enable Int0
On Int0 Stopbutton
Print "I2C EEPROM Test Program."
Prog0:
Do
Inputhex "|d|ump 1x16, |l|ap 16x16, |b|ytewrite = " , A
Select Case A
Case 13 : Goto Prog1 'd dump 16-byte
Case 11 : Gosub Prog2 'b byte írás
Case 21 : Goto Prog4 'l lap 16x16 byte
End Select
Loop
Prog1:
Szamlalo = 1023
Inputhex "dump 1x16byte address = " , I2c_eeprom_address_desired
Do
Print Hex(i2c_eeprom_address_desired) ; " " ;
For Tom = 0 To 15
Call I2c_ram_read(i2c_eeprom_address_desired)
Print ; Hex(data_work_var) ; ;
Incr I2c_eeprom_address_desired
Decr Szamlalo
Next
Print " tovabb|ent| out|esc|"
K = Waitkey()
If K = 27 Then Goto Prog0
Loop Until Szamlalo = 0
Prog4:
Szamlalo = 256
Inputhex "dump 16x16 byte address = " , I2c_eeprom_address_desired
Do
Print Hex(i2c_eeprom_address_desired) ; " " ;
For Tom = 0 To 15
Call I2c_ram_read(i2c_eeprom_address_desired)
Print ; Hex(data_work_var) ; ;
Incr I2c_eeprom_address_desired
Decr Szamlalo
Next
Print ""
Loop Until Szamlalo = 0
Goto Prog0
End
'**********************************************************************
'** Define Subroutines **
'**********************************************************************
Sub I2c_ram_read(address_desired As Word)
I2c_eeprom_address_low_byte = Low(address_desired)
I2c_eeprom_address_high_byte = High(address_desired)
I2cstart
I2cwbyte Eeprom_chip_write_command
I2cwbyte I2c_eeprom_address_high_byte
I2cwbyte I2c_eeprom_address_low_byte
I2cstart
I2cwbyte Eeprom_chip_read_command
I2crbyte Data_work_var , Nack
If Err = 0 Then
Print " " ;
Else
Print "Read failed: " ;
End If
I2cstop
Waitms 10
End Sub
Prog2:
Inputhex "bytewrite address = " , I2c_eeprom_address_desired
Prog3:
Call I2c_ram_read(i2c_eeprom_address_desired)
Print Hex(i2c_eeprom_address_desired) ; " " ; Hex(data_work_var);
Inputhex " = " , Data_work_var
Call I2c_ram_write(i2c_eeprom_address_desired , Data_work_var) ' Write it to the EEPROM.
Incr I2c_eeprom_address_desired
Inputhex , Quit
If Quit = &H1A Then Goto Prog0
Goto Prog3
Return
'**********************************************************************
'** Define Subroutines **
'**********************************************************************
Sub I2c_ram_write(address_desired As Word , Content As Byte)
I2c_eeprom_address_low_byte = Low(address_desired)
I2c_eeprom_address_high_byte = High(address_desired)
I2cstart
I2cwbyte Eeprom_chip_write_command
I2cwbyte I2c_eeprom_address_high_byte
I2cwbyte I2c_eeprom_address_low_byte
I2cwbyte Content
If Err = 0 Then
Print "Write is good: Location: " ; Hex(address_desired) ; "=" ; Hex(data_work_var);
Print " the next |enter|, out |q|"
Else
Print "Write failed: Location: " ; Address_desired
End If
I2cstop
Waitms 50
End Sub
Stopbutton:
Wait 10
Return
Ezzel a progival lehet az attiny2313 board v11. panelon az eeprom-ot olvasni illetve byte-onként irni.
Jtama
