INFO - FAQ - CC2-Forum - CCPro-Forum |
> Hallo ! > Wird Euch interessieren , habe eine Ausgabe für I2C programmiert und ist getestet. > '************************************************************* > ' * > ' C-Control/MICRO I2C_5.BAS * > ' (C) JPM 03.08.2004 * > ' Aufgabe: * > ' * > ' - Porterweiterung für MICRO ueber den I2C-Bus * > ' - Ansteuerung eines PCF8574 momentan nur Ausgabe !!!! * > ' - SDA am Port 5 * > ' - SCL am Port 6 * > '************************************************************* > ' --- Definitionen -------------------- > define SDA port[5] > define SCL port[6] > '-------------------------- > '---- Variablen ----------- > '-------------------------- > define Daten byte[1] > define B1 bit[1] > define B2 bit[2] > define B3 bit[3] > define B4 bit[4] > define B5 bit[5] > define B6 bit[6] > define B7 bit[7] > define B8 bit[8] > define Zaehler byte[2] > define N byte[3] > '------------------------------------------------------------- > SDA = 1 > SCL = 1 > '_____________________________________________________________ > > ' --- Programmoperationen ------------- > > #Loop > for Zaehler = 0 to 255 > gosub Start > Daten = 64 '1.Adresse PCF8574 > gosub I2C_Write > Daten = Zaehler 'Daten ausgeben > gosub I2C_Write > gosub Stop > pause 10 'wenn Pause entfent wird , sieht man die Geschwindigkeit von MICRO > next > goto loop > > #Start > SDA=0 > SCL=1 > return > > #Stop > SCL=1 > SDA=1 > return > > #I2C_WRITE > if B8=ON then SDA=ON > gosub pulse_SCL > if B7=ON then SDA=ON > gosub pulse_SCL > if B6=ON then SDA=ON > gosub pulse_SCL > if B5=ON then SDA=ON > gosub pulse_SCL > if B4=ON then SDA=ON > gosub pulse_SCL > if B3=ON then SDA=ON > gosub pulse_SCL > if B2=ON then SDA=ON > gosub pulse_SCL > if B1=ON then SDA=ON > gosub pulse_SCL > gosub pulse_SCL ' 9. Impuls ACK vom Slave > return > > #pulse_SCL > SCL=0 > SCL=1 > SCL=0 > SDA=0 > return > end > > Hallo Jan, bitte vergiss nicht, daß die C-Micro mit dem Command for Zaehler = 0 to 255 ihre Schwiedrigkeiten hat.Die Variable "Zähler" wird zwar von 0 bis 254, aber NIE bis 255 hochgezählt !! Liebe Grüße aus Wien ! |
Antwort schreiben |