I2C freezer

Başlatan buntger, 15 Ekim 2016, 08:47:11

buntger

Hi,

I have mounted on a protoboard with PIC18F26K22 and accelerometer MMA7455, when I take a while to see values on the screen freezes (hang down), I have to do a reset.

Now the pic works to 5V and MMA7455 works 3.3V , Among them is connected TXS0108EPWR (8-Bit Bi-directional, Level-Shifting, Voltage Translator for Open-Drain and Push-Pull Applications)

Anyway, when the Pic and MMA7455 operate to 3.3 volts,
with their respective resistors (2.2K) on the SDA and SCL lines to 3.3V also froze the I2C bus

What causes might be?

My Library MMA7455:
$ifndef __MMA7455_INC_
$define __MMA7455_INC_
'
  
' MMA7455 variables
'
	Dim ACE_X As Byte   ' Read Value X
	Dim ACE_Y As Byte   ' Read Value Y
	Dim ACE_Z As Byte   ' Read Value Z
        Dim OFF_X As Byte  ' Value Offset X
	Dim OFF_Y As Byte  ' Value Offset Y
	Dim OFF_Z As Byte  ' Value Offset Z
'

' MMA7455 register addresses
'
     $define C_REG_MM7  $16   ' 16 DIRECCION CONTROL REGISTRO
     $define RE_ACELERO $3A    ' 0011 1011 3A ALIAS DEL CODIGO PARA LEER EL ACELEROMETRO
     $define WR_ACELERO $3B   ' 0011 1010 3B ALIAS DEL CODIGO PARA ESCRIBIR EL ACELEROMETRO
     $define LEO_X_REG  $06    ' Read register X (8-Bit)
     $define LEO_Y_REG  $07    ' Read register Y (8-Bit)
     $define LEO_Z_REG  $08   ' Read register Z (8-Bit)
     

$ifndef False
    $define False 0
$endif
$ifndef True
    $define True 1
$endif

'----------------------------------------------------------------------------
    GoTo _MMA7455_Main                   ' Jump over the routines
'----------------------------------------------------------------------------
    
$define MMA7455_W_OFFSET(hXX, hYY, hZZ) '
    OFF_X = hXX                                 '
    OFF_Y = hYY                                 '
    OFF_Z  = hZZ                                '
    GoSub _MMA7455_W_OFFSET

_MMA7455_W_OFFSET:
    
    HBStart	 	 	 		   	               ' Open I2C  05 = 000 (SPI) 1(Status) 01(2G) 00 (Solo para 10Bits)
     HBusOut WR_ACELERO ,C_REG_MM7,[$65]    ' Write MCTL Register $16, sending in a value of 0x65 to set up the device 
     HBusOut WR_ACELERO ,REG_XOFFL,[OFF_X] ' X LowByte Pag 14 DataSheet Calibracion
     HBusOut WR_ACELERO ,REG_YOFFL,[OFF_Y]  ' Y LowByte
     HBusOut WR_ACELERO ,REG_ZOFFL,[OFF_Z] ' Z LowByte
   HBStop	                          
Return

        
$define MMA7455_ReadDate() GoSub _MMA7455_ReadDate

_MMA7455_ReadDate:

   ' MMA7455_SendDate
   
    HBStart
     HBusIn RE_ACELERO ,LEO_X_REG,[ACE_X] 
     HBusIn RE_ACELERO ,LEO_Y_REG,[ACE_Y]
     HBusIn RE_ACELERO ,LEO_Z_REG,[ACE_Z]
    HBStop
    DelayMS 100			
      
Return

'----------------------------------------------------------------------------
_MMA7455_Main:

$endif  ' _MMA7455_INC_


THX