ESP8266 Developer Zone The Official ESP8266 Forum 2015-09-05T15:02:27+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1005 2015-09-05T15:02:27+08:00 2015-09-05T15:02:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1005&p=3568#p3568 <![CDATA[Re: GPIO problem in Interfacing with TM1637 Display Driver]]> https://github.com/eriksl/esp8266-universal-io-bridge

I will make a new release soon (but no change in I2C code anyway).

I hope it gives a clue to where the actual problem is, as is gives state and actual problem on error.

Statistics: Posted by eriksl — Sat Sep 05, 2015 3:02 pm


]]>
2015-09-05T10:54:11+08:00 2015-09-05T10:54:11+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1005&p=3566#p3566 <![CDATA[Re: GPIO problem in Interfacing with TM1637 Display Driver]]>
Thanks for your reply.

Can I get your firmware ?

Thanks & regards,
Prakash

Statistics: Posted by parmar7725274 — Sat Sep 05, 2015 10:54 am


]]>
2015-09-05T02:21:24+08:00 2015-09-05T02:21:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1005&p=3558#p3558 <![CDATA[Re: GPIO problem in Interfacing with TM1637 Display Driver]]>
My universal I/O bridge can assign SDA and SCL to random GPIO's. I'm always using GPIO4 and GPIO5, but GPIO0 and GPIO2 should work just as well (provided they're pulled up properly). I don't really trust the example I2C code from Espressif, it's really far too simple. So I suggest giving my firmware a shot, just to be sure. It has a function to send and receive arbitrary byte strings over i2c. I am curious to know if it works indeed, I2C over GPIO0 and GPIO2. It might be that the boot loader tries to send some data over GPIO0 or GPIO2 during boot and that may fool the I2C client into thinking it sees a start condition. In that case you should do an I2C bus reset procedure after boot (which, Espressif, of course, did not implement).

Statistics: Posted by eriksl — Sat Sep 05, 2015 2:21 am


]]>
2015-08-29T20:43:07+08:00 2015-08-29T20:43:07+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1005&p=3492#p3492 <![CDATA[Re: GPIO problem in Interfacing with TM1637 Display Driver]]> GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO)), GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO))) | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //open drain;
是错误的,希望他们能提出改进方法

Statistics: Posted by xad74 — Sat Aug 29, 2015 8:43 pm


]]>
2015-09-03T14:07:13+08:00 2015-08-26T01:47:54+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1005&p=3432#p3432 <![CDATA[GPIO problem in Interfacing with TM1637 Display Driver]]>
In our current product prototype we want to interface 6 Digit 7 segment display. The display is based on TM1637 display driver. TM1637 display driver use I2C for communication and I'm using GPIO 0 ( SCL ) and 2 ( SDA ) of ESP for communication.

Problem I'm facing is after sending START bytes to TM1637 Display driver I'm not able to get acknowledgement signal on GPIO2. Display is working fine with other development board with same logic. I also attach Code for a reference.

Any one have Idea where I'm wrong ? Is there any problem with GPIO initialization ?
Please help me !

Thanks & regards,
Prakash

Code:


#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "tm1637.h"
#include "tm1637font.h"

/*  i2c Methods for handling data transfer to and from the tm1637. */

void ICACHE_FLASH_ATTR delay_us( uint8_t i )
{
   for( ; i>0; i-- );
}
/******************************************************************************
 * FunctionName :
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR i2c_start(void)
{
   os_printf("i2c_start - IN \n");

   I2C_MASTER_SCL_HIGH( );

   I2C_MASTER_SDA_HIGH( );

   delay_us(2);

        I2C_MASTER_SDA_LOW( );

        os_printf("i2c_start - OUT \n");
}

/******************************************************************************
 * FunctionName :
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR i2c_ack (void)
{
   uint8 ret = 0;

   os_printf("i2c_ack - IN \n");

   I2C_MASTER_SCL_LOW( );

   delay_us (5);

   PIN_PULLUP_EN( I2C_MASTER_SDA_MUX );               // enable pin PULL-UP
   GPIO_DIS_OUTPUT( GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ));    // set I2C_MASTER_SDA_GPIO as input

       while( 1 )
      {
          ret = GPIO_INPUT_GET( GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ) );
          os_printf("- %d ", ret);
          if(ret)
             break;
    }

    I2C_MASTER_SCL_HIGH();

    delay_us( 2 );

    I2C_MASTER_SCL_LOW();

    os_printf("i2c_ack - OUT \n");
}

/******************************************************************************
 * FunctionName :
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR i2c_stop (void)
{
    os_printf("i2c_stop - IN \n");

   I2C_MASTER_SCL_LOW();

   delay_us (2);

   I2C_MASTER_SDA_LOW();
   delay_us (2);

        I2C_MASTER_SCL_HIGH();
        delay_us (2);

        I2C_MASTER_SDA_HIGH();

        os_printf("i2c_stop - OUT \n");
}

/******************************************************************************
 * FunctionName :
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR i2c_write ( uint8_t oneByte )
{
    uint8_t i;

    os_printf("i2c_write - IN\n");

    for (i=0; i<8; i++)
    {
       
       I2C_MASTER_SCL_LOW();

       ( oneByte & 0x01 ) ? I2C_MASTER_SDA_HIGH() : I2C_MASTER_SDA_LOW();

       delay_us (3);

        oneByte = oneByte >> 1;

        I2C_MASTER_SCL_HIGH();
        delay_us (3);
    }

    os_printf("i2c_write - OUT \n");
}

/******************************************************************************
 * FunctionName : i2c_master_gpio_init
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_gpio_init(void)
{
   os_printf("\ni2c_master_gpio_init - IN\n");

       ETS_GPIO_INTR_DISABLE() ;

       PIN_FUNC_SELECT(   I2C_MASTER_SDA_MUX,
                      I2C_MASTER_SDA_FUNC
                   );

       PIN_FUNC_SELECT(   I2C_MASTER_SCL_MUX,
                      I2C_MASTER_SCL_FUNC
                   );

    GPIO_REG_WRITE(   GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO)),
                      GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO))) |
                      GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE));             //open drain;
      
        GPIO_REG_WRITE(   GPIO_ENABLE_ADDRESS,
                      GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << I2C_MASTER_SDA_GPIO));
   
       GPIO_REG_WRITE(   GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SCL_GPIO)),
                     GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_MASTER_SCL_GPIO))) |
                     GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE));                //open drain;
   
        GPIO_REG_WRITE( GPIO_ENABLE_ADDRESS,
                       GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << I2C_MASTER_SCL_GPIO) );
   
        ETS_GPIO_INTR_ENABLE() ;

      GPIO_OUTPUT_SET(GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ), 0);   // set I2C_MASTER_SDA_GPIO as Low-level output

       PIN_PULLUP_EN( I2C_MASTER_SDA_MUX );               // enable pin PULL-UP
       GPIO_DIS_OUTPUT( GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ));    // set I2C_MASTER_SDA_GPIO as input

       GPIO_OUTPUT_SET( GPIO_ID_PIN( I2C_MASTER_SCL_GPIO ), 0);    // set I2C_MASTER_SDA_GPIO as Low-level output

       os_printf("i2c_master_gpio_init - OUT\n");

}

/******************************************************************************
 * FunctionName :
 * Description  :
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR display( void )
{
   int i;

   i2c_start();
   i2c_write( 0x40 );
   i2c_ack();
   i2c_stop();

   i2c_start();
   i2c_write( 0xC0 );   // Set the starting address
   i2c_ack();
   for( i = 1; i <= TM1637_DIGITS; i++ )
   {
      i2c_write( 0xff );
      i2c_ack( );
   }
   i2c_stop();

   i2c_start();
   i2c_write( 0x8F );
   i2c_ack();
   i2c_stop();

}



here is a macro definitions :

Code:

#ifndef __tm1637_H__
#define __tm1637_H__

void i2c_master_gpio_init( void );
void display( void );

#define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U
#define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_GPIO0_U

#define I2C_MASTER_SDA_GPIO 2
#define I2C_MASTER_SCL_GPIO 0

#define I2C_MASTER_SDA_FUNC FUNC_GPIO2
#define I2C_MASTER_SCL_FUNC FUNC_GPIO0

#define I2C_MASTER_SCL_LOW( )    \
   GPIO_OUTPUT_SET(GPIO_ID_PIN( I2C_MASTER_SCL_GPIO ), 0 )

#define I2C_MASTER_SCL_HIGH( )    \
   GPIO_OUTPUT_SET(GPIO_ID_PIN( I2C_MASTER_SCL_GPIO ), 1 )

#define I2C_MASTER_SDA_LOW( )    \
   GPIO_OUTPUT_SET(GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ), 0 )

#define I2C_MASTER_SDA_HIGH( )    \
   GPIO_OUTPUT_SET(GPIO_ID_PIN( I2C_MASTER_SDA_GPIO ), 1 )

#define TM1637_DIGITS            6

#endif

Statistics: Posted by parmar7725274 — Wed Aug 26, 2015 1:47 am


]]>