Goedenmorgen 
Is er al eens iemand met picbasic bezig geweest om de snelheid van de i2c (hardware) te verlagen / vergroten ?
dit is het eerste stuk programma, Als ik de Define i2c slow aanzet dan draait i2c op 100KHz, als ik deze uitzet draait het geheel op 1 MHz, is er een mogelijkheid dit op 400KHz te laten draaien ?
ik heb pullups van 1K genomen maar vind de signaaltjes bij 1 MHz niet echt mooi meer, onderstaand de init programma's e.d. van de i2c bus.
Onderstaand wat delen van het programma om misschien eens ergens te gebruiken...
Eerste deel programma.
Device = 18F4550
'DEFINE I2C_SLOW 1Config_Start
PLLDIV = 5 ; Divide by 5 (20 MHz oscillator input)
CPUDIV = OSC1_PLL2 ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
FOSC = HSPLL_HS ; HS oscillator, PLL enabled, HS used by USB
VREGEN = OFF ; USB voltage regulator disabled
MCLRE = On ; MCLR pin enabled; RE3 input pin disabled
LVP = OFF ; Single-Supply ICSP disabled
Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Config_End
Io configuratie van de MCP23017.
initI2C:
' external
'Output op adres 1
HBStart
HBusOut %01000010, $00, [%00000000]
HBusOut %01000010, $01, [%00000000]
HBStop'Input met pullups adres 2
HBStart
HBusOut %01000100, $00, [%11111111]
HBusOut %01000100, $01, [%11111111]
HBusOut %01000100, $0C, [%11111111]
HBusOut %01000100, $0D, [%11111111]
HBStop
'Input met pullups adres 2
HBStart
HBusOut %01000110, $00, [%11111111]
HBusOut %01000110, $01, [%11111111]
HBusOut %01000110, $0C, [%11111111]
HBusOut %01000110, $0D, [%11111111]
HBStop
Return
Inlezen van 32 inputs:
readI2C:
HBStart
HBusIn %01000101, $12, [row1]
HBusIn %01000101, $13, [row2]
HBStop
HBStart
HBusIn %01000111, $12, [row3]
HBusIn %01000111, $13, [row4]
HBStop
Return
Alsook de instructies om Read en Write te doen bij een 24FC512 EEprom met word variabelen.
writeEprom:
locationprom = location * 2
HBStart
HBusOut %10100000
HBusOut locationprom.HighByte
HBusOut locationprom.LowByte
HBusOut value.HighByte
HBusOut value.LowByte
HBStop
DelayMS 5
ReturnreadEprom:
locationprom = location * 2
HBStart
HBusOut %10100000
HBusOut locationprom.HighByte
HBusOut locationprom.LowByte
HBReStart
HBusOut %10100001
HBusIn value.HighByte
HBStop
HBReStart
HBusOut %10100001
HBusIn value.LowByte
HBStop
Return
Arco
Special Member
Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Pull-ups van 1KOhm zijn veel te hoog in FastMode+ (1MHz).
Er moet minimaal 20mA stroom lopen, dus bij 5v is dat 5/0.02=250 Ohm.
