-
-
Neuer Benutzer
Öfters hier
Serielles Eeprom
Hallo zusammen!
Ich habe an meinen PIC 16F84 ein serielles Eeprom angeschlossen.
Hier der Schaltplan:
Bild 1:
Bild hier
[/img]Nun möchte ich Daten aus dem seriellen Eeprom auslesen und
in den internen Eeprom vom Pic 16F84 schreiben.
Hier mein Program:
B0 var byte
B1 var byte
B2 var byte
cont con %10101110
for b1=1 to 50
I2cread PORTB.4,PORTB.5,cont,b1,[B2]
pause 10
write b1,b2
next b1
Ab und zu wird etwas in den internen Eeprom geschrieben,aber nicht die Daten aus dem seriellen Eeprom.
???Was mache ich falsch.???
Bitte um Hilfe!
MFG
R.H.D.B.
Hier ist die Hilfe von PicBasicPro aufgelistet:
I2CREAD DataPin,ClockPin,Control,{Address,}[Var{,Var...}]{,Label}
Send Control and optional Address bytes out the ClockPin and DataPin and store the byte(s) received into Var. ClockPin and DataPin may be a <constants.html>, 0-15, or a <variables.html> that contains a number 0-15 (e.g. B0) or a <pins.html> name (e.g. PORTA.0). I2CREAD and I2CWRITE <i2cwrite.html> can be used to read and write data to a serial EEPROM with a 2-wire I2C interface such as the Microchip 24LC01B and similar devices. This allows data to be stored in external non-volatile memory so that it can be maintained even after the power is turned off. These commands operate in the I2C master mode and may also be used to talk to other devices with an I2C interface like temperature sensors and A/D converters.
The upper 7 bits of the Control byte contain the control code along with chip select or additional address information, depending on the particular device. The low order bit is an internal flag indicating whether it is a read or write command and should be kept clear. This format for the Control byte is different than the format used by the original PicBasic Compiler. Be sure to use this format with PicBasic I2C operations. For example, when communicating with a 24LC01B, the control code is %1010 and the chip selects are unused so the Control byte would be %10100000 or $A0. Formats of Control bytes for some of the different parts follows:
Bild hier
bbb = block select (high order address) bits
ddd = device select bits
xxx = don't care
The Address size sent (byte or word) is determined by the size of the <variables.html> that is used. If a byte-sized <variables.html> is used for the Address, an 8-bit address is sent. If a word-sized <variables.html> is used, a 16-bit address is sent. Be sure to use the proper sized <variables.html> for the device you wish to communicate with. Constants <constants.html> should not be used for the address as the size can vary dependent on the size of the <constants.html>. If a word-sized Var is specified, 2 bytes are read and stored into the Var high byte first, followed by the low byte. This order is different than the way <variables.html> are normally stored, low byte first.
A modifier, STR, may be included before the variable name. This can load an entire array (string) at once. If STR is specified, the following <variables.html> must be the name of a word or byte array, followed by a backslash (\) and a count:
a VAR byte[8]
I2CREAD PORTC.4,PORTC.3,$a0,0,[STR a\8]
If a word-sized array is specified, the 2 bytes that comprise each element are read low byte first. This is the opposite of how simple words are read and is consistent with the way the compiler normally stores word-sized <variables.html>. If the optional Label <line-labels.html> is included, this label <line-labels.html> will be jumped to if an acknowledge is not received from the I2C device. The I2C instructions can be used to access the on-chip serial EEPROM on the 12CExxx and 16CExxx devices. Simply specify the <pins.html> names for the appropriate internal lines as part of the I2C command and place the following DEFINE at the top of the program:
DEFINE I2C_INTERNAL 1
For the 12CE67x devices, the data line is GPIO.6 and the clock line is GPIO.7. For the 16CE62x devices, the data line is EEINTF.1 and the clock line is EEINTF.2. See the Microchip data sheets for these devices for more information. The timing of the I2C instructions is set so than standard speed devices (100KHz) will be accessible at clock speeds up to 8MHz. Fast mode devices (400KHz) may be used up to 20MHz. If it is desired to access a standard speed device at above 8MHz, the following DEFINE <define.html> should be added to the program:
DEFINE I2C_SLOW 1
Transfer on the I2C bus can be paused by the receiving device by its holding the clock line low. To enable this the following DEFINE <define.html> should be added to the program:
DEFINE I2C_HOLD 1
The I2C clock and data lines should be pulled up to Vcc with a 4.7K resistor, as they are both run in a bi-directional open-collector manner. To make the I2C clock line bipolar instead of open-collector the following DEFINE <define.html> may be added to the program:
Das funktioniert auch nicht:
DEFINE I2C_SCLOUT 1
addr VAR byte
cont CON %10100000
addr = 17 ' Set address to 17
' Read data at address 17 into B2
I2CREAD PORTA.0,PORTA.1,cont,addr,[B2]
[/img]
-
Erfahrener Benutzer
Roboter Genie
ich hatte dir ne pn geschrieben, wegen was anderem... ich hab mir pic basic pro angesehen. ich find das nicht sooo doll.... besser ist z.b. PIC-BASIC-II
was dein problem angeht, kann ich dir leider nicht helfen, weil ich sowas noch nie gemacht hab. in den pic-basic pro-files gibt es doch sicherlich nen demo-prog, was in den internen speicher schreibt (äh was heißt sicherlich, sogar SICHER, weil ichs heute morgen noch gelesen hab). probier das doch erstmal aus und modifizier es dann. vielleicht findest du auch ne demo für das lesen aus seriellen eeproms. hier gibts demo-files. vielleicht ist da was dabei, was nicht im lieferumfang ist.
sag mal, du hast pic basic pro aber nicht für $237.47 gekauft, oder??
-
Neuer Benutzer
Öfters hier
Serielles Eeprom
Hi nochmal!
Ich habe die Demos getestet und modifiziert.
Mit dem komme ich nicht zurecht:
%1010bbb0
Ich habe einfach die b's mit mit verschiedenen kombinationen
aus 1 und 0 ersetzt.
Aber das ging auch nicht.
Wie gesagt ab und zu werden Daten gelesen und im internen Eeprom
gespeichert.
Aber nicht die daten die im seriellen Eeprom gespeichert sind.
Wer kennt sich damit aus?
MFG
R.H.D.B
Ich werd mir mal PicBasic II anschauen.
-
Erfahrener Benutzer
Roboter Genie
noch nen tip: il basic http://www.il-online.de/
für deine zwecke ideal! das prob ist ganz nett, jedoch ist die demo nur für den 16c84, man kann die hex-dateien aber auch auf nen 16f84 brennen. ansonsten keine einschränkung der demo..
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
-
Foren-Regeln
Lesezeichen