| Modelo | Pines de direccion de memoria | Memoria |
| M27C256 | 15 | 32Kbytes = 256Kbits |
| M27C512 | 16 | 64Kbytes = 512Kbits |
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Const Out_Port As Integer = &H378 '0x378 o 888
Private Const In_Port As Integer = Out_Port + 1
Function decTObin(a As Long) As String
If Int(a / 2) = 0 Then decTObin = decTObin & a Mod 2 Else: decTObin = decTObin(Int(a / 2)) & a Mod 2
End Function
Function binTOdec(a As String) As Long
If Len(a) = 1 Then binTOdec = Val(a) Else: binTOdec = Val(Left(a, 1)) * 2 ^ (Len(a) - 1) + binTOdec(Right(a, Len(a) - 1))
End Function
Private Function ClearBuffer(ByVal intBuffer As Integer)
Select Case intBuffer
Case 1 'Buffer 1
ClrPortBit Out_Port + 2, 1 'Desactivo Latch del buffer1
SetPortBit Out_Port + 2, 3 'Activo Latch del buffer2
Case 2 'Buffer 2
SetPortBit Out_Port + 2, 1 'Activo Latch del buffer1
ClrPortBit Out_Port + 2, 3 'Desactivo Latch del buffer2
End Select
'Limpio el Bus de 8 bits
ClrPortBit Out_Port, 0
ClrPortBit Out_Port, 1
ClrPortBit Out_Port, 2
ClrPortBit Out_Port, 3
ClrPortBit Out_Port, 4
ClrPortBit Out_Port, 5
ClrPortBit Out_Port, 6
ClrPortBit Out_Port, 7
'DoEvents 'No hace falta
'Dejo ambos Latches habilitados
SetPortBit Out_Port + 2, 1
SetPortBit Out_Port + 2, 3
End FunctionPrivate Function LoadBuffer(ByVal intBuffer As Integer, ByRef blnBits() As Boolean) 'Envio un array de booleans a un determinado buffer
Dim intIndex As Integer
Select Case intBuffer
Case 1 'Buffer 1
ClrPortBit Out_Port + 2, 1 'Desactivo Latch del buffer1
SetPortBit Out_Port + 2, 3 'Activo Latch del buffer2
Case 2 'Buffer 2
SetPortBit Out_Port + 2, 1 'Activo Latch del buffer1
ClrPortBit Out_Port + 2, 3 'Desactivo Latch del buffer2
End Select
'Recorro todo el array y seteo el bus con sus valores
For intIndex = LBound(blnBits) To UBound(blnBits)
If blnBits(intIndex) Then 'aca hay un 1
SetPortBit Out_Port, intIndex 'seteo el bit intIndex (que a su vez es correlativo con el bucle) con 1
Else
ClrPortBit Out_Port, intIndex 'aca lo seteo con 0
End If
Next intIndex
DoEvents
'Dejo ambos Latches habilitados
SetPortBit Out_Port + 2, 1
SetPortBit Out_Port + 2, 3
'Limpio el bus de 8 bits
ClrPortBit Out_Port, 0
ClrPortBit Out_Port, 1
ClrPortBit Out_Port, 2
ClrPortBit Out_Port, 3
ClrPortBit Out_Port, 4
ClrPortBit Out_Port, 5
ClrPortBit Out_Port, 6
ClrPortBit Out_Port, 7
End Function
Private Function Send2Bytes(ByRef blnArr() As Boolean) 'Parte en 2 un array de Booleans para enviar 8 bits a un buffer y 8 bits al otro buffer
Dim blnArr1(7) As Boolean
Dim intIndex As Integer
For intIndex = 0 To 7 'Paso el array tal cual desde el 0 hasta el 7 (8)
blnArr1(intIndex) = blnArr(intIndex)
Next intIndex
Call LoadBuffer(1, blnArr1) 'Lo cargo en buffer1
For intIndex = 0 To 7 'Paso el array desde el index 8 a 15 (8)
blnArr1(intIndex) = blnArr(intIndex + 8)
Next intIndex
Call LoadBuffer(2, blnArr1) 'Lo cargo en buffer2
End Function
Private Function SelectMemory(ByVal lngPosition As Long) 'Selecciono la posicion en memoria que quiero leer
Dim strBin As String
Dim intIndex As Integer
Dim blnArr(15) As Boolean
strBin = decTObin(lngPosition) 'Paso la posicion a binario
strBin = String$(16 - Len(strBin), "0") & strBin 'Hago que el len siempre sea de 16 (rellenar lo que falta con 0)
'Cargo el array de 16 items a partir del string en binario
blnArr(12) = IIf(Mid$(strBin, 1, 1) = "1", True, False) 'estos son los que estan cruzados
blnArr(13) = IIf(Mid$(strBin, 2, 1) = "1", True, False) ' *
blnArr(14) = IIf(Mid$(strBin, 3, 1) = "1", True, False) ' *
blnArr(15) = IIf(Mid$(strBin, 4, 1) = "1", True, False) ' *
blnArr(11) = IIf(Mid$(strBin, 5, 1) = "1", True, False)
blnArr(10) = IIf(Mid$(strBin, 6, 1) = "1", True, False)
blnArr(9) = IIf(Mid$(strBin, 7, 1) = "1", True, False)
blnArr(8) = IIf(Mid$(strBin, 8, 1) = "1", True, False)
blnArr(4) = IIf(Mid$(strBin, 9, 1) = "1", True, False) 'estos tambien estan cruzados
blnArr(5) = IIf(Mid$(strBin, 10, 1) = "1", True, False) ' *
blnArr(6) = IIf(Mid$(strBin, 11, 1) = "1", True, False) ' *
blnArr(7) = IIf(Mid$(strBin, 12, 1) = "1", True, False) ' *
blnArr(3) = IIf(Mid$(strBin, 13, 1) = "1", True, False)
blnArr(2) = IIf(Mid$(strBin, 14, 1) = "1", True, False)
blnArr(1) = IIf(Mid$(strBin, 15, 1) = "1", True, False)
blnArr(0) = IIf(Mid$(strBin, 16, 1) = "1", True, False)
Call Send2Bytes(blnArr)
End FunctionPrivate Function ReadByteASCII() As String
'Direccion en 4512 | Bit
' A | 6
' B | 5
' C | 4
Dim strBin As String
Dim blnOut(7) As Boolean
ClrPortBit Out_Port, 6
ClrPortBit Out_Port, 5
ClrPortBit Out_Port, 4
strBin = IIf(ReadPin(1), "1", "0")
SetPortBit Out_Port, 6
ClrPortBit Out_Port, 5
ClrPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
ClrPortBit Out_Port, 6
SetPortBit Out_Port, 5
ClrPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
SetPortBit Out_Port, 6
SetPortBit Out_Port, 5
ClrPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
ClrPortBit Out_Port, 6
ClrPortBit Out_Port, 5
SetPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
SetPortBit Out_Port, 6
ClrPortBit Out_Port, 5
SetPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
ClrPortBit Out_Port, 6
SetPortBit Out_Port, 5
SetPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
SetPortBit Out_Port, 6
SetPortBit Out_Port, 5
SetPortBit Out_Port, 4
strBin = strBin & IIf(ReadPin(1), "1", "0")
ReadByteASCII = Chr$(binTOdec(strBin))
End Function
'by TodoRobot
Private Function ReadPin(ByVal intPin As Integer) As Boolean
Dim Lectura As Byte
Dim Estado(3) As Byte
Dim Estado_Str(3) As String
Dim Bucle As Byte
Lectura = PortIn(In_Port) 'leo el puerto de entrada
'filtro solo los bit's que necesito conocer
Estado(0) = Lectura And &H8 '= 00001000 en Binario
Estado(1) = Lectura And &H10 '= 00010000 en Binario
Estado(2) = Lectura And &H20 '= 00100000 en Binario
Estado(3) = Lectura And &H40 '= 01000000 en Binario
ReadPin = Estado(intPin) <> 0
End Function
Sub Main()
Dim lngIndex As Long
Open App.Path & "\dump.rom" For Binary Access Write As #1
'Nota aca: si vas a leer la memoria M27C512, el numero que tenes que poner es 65535
' si vas a leer la memoria M27C256, el numero que tenes que poner es 32767
For lngIndex = 0 To 65535
Call SelectMemory(lngIndex)
Put #1, , ReadByteASCII
Next lngIndex
Close #1
End Sub=D por fin funco! la verdad muy buena onda todo esto. Se que fue un dolor de cabeza poner todo junto y depurarlo pero valio la pena, ahora gente como yo se entretiene mirando los diagramas y todo =D
Cuco Excelente Aporte, por Casualidad no tendras un esquema para la grabar y borrar Chips SIM, que vaya por el puerto USB???