I having issues in connecting a small oled display purchesed from Adafruit. All the example they have are based on arduino library! The two example code I found in this forum do not work. It is a whole week I am trying to have this little thing to work without any luck. So I decided to check wich is the true address of the device I am wrking on (documentation I found says $3c; $3d ; $78 ; $7A and more) I did check all of them without any luck.
The code below is supposed to be an I2C address scanner but I am lost on how to detect the ACKNOWLEDGMENT of the device any suggestion or advice?
Thank you for the attentionCode:;----[16F88 Hardware Configuration]--------------------------------------------- #IF __PROCESSOR__ = "16F88" #DEFINE MCU_FOUND 1 #CONFIG cfg1 = _INTRC_IO ; INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin cfg1&= _WDT_OFF ; WDT disabled cfg1&= _PWRTE_OFF ; PWRT disabled cfg1&= _MCLR_ON ; RA5/MCLR/VPP pin function is MCLR cfg1&= _BODEN_OFF ; BOR disabled cfg1&= _LVP_OFF ; RB3 is digital I/O, HV on MCLR must be used for programming cfg1&= _CPD_OFF ; Code protection off cfg1&= _WRT_PROTECT_OFF ; Write protection off cfg1&= _DEBUG_OFF ; In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins cfg1&= _CCP1_RB0 ; CCP1 function on RB0 cfg1&= _CP_OFF ; Code protection off __CONFIG _CONFIG1, cfg1 cfg2 = _FCMEN_ON ; Fail-Safe Clock Monitor enabled cfg2&= _IESO_ON ; Internal External Switchover mode enabled __CONFIG _CONFIG2, cfg2 #ENDCONFIG #ENDIF ;----[Verify Configs have been specified for Selected Processor]---------------- ; Note: Only include this routine once, after all #CONFIG blocks #IFNDEF MCU_FOUND #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]" #ENDIF LED var PortB.3 I2C_Dev var byte SCL var PortA.3 ' I2C Clock PortA.3 SDA var PortA.2 ' I2C Data PortA.2 False con 0 True con 1 Flag_ack var bit I VAR BYTE DC var byte say var byte DEFINE HSER_RCSTA 90h ' En. s.port & cont receive DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 12 ' 9600 Baud @ 32MHz, 0,16% DEFINE HSER_CLROERR 1 ' Clear overflow automatically '============================================================================== Hserout ["System ready"] For I = 1 to 10 Led = !Led pause 100 next I hserout ["Address scannining in progress..."] for I = $08 to $77 step 2 I2CWrite SDA,SCL,I2C_Dev,[DC] If Flag_Ack = true then say = I pause 2000 Led = !Led Next I hserout ["Address found = ",dec say] end
Alberto




Bookmarks