This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to initialize TVP5158 with dm6437

Other Parts Discussed in Thread: TVP5158, TVP5146, TVP5150

 

Hello everyone:

           I used dm6437 initialization tvp5158 unsuccessful! Procedure is as follows:

    rom_version = tvp5146_rget( 0x04 );

    chipid_msb  = tvp5146_rget( 0x08 );

    chipid_lsb  = tvp5146_rget( 0x09 ); 

    //TVP5158_softReset();  //重启

    _waitusec( 1000 );     

    tvp5146_rset( 0x14, 0xe4 );
    //tvp5146_rset( 0x13, 80 ); //Chrominance Saturation
    tvp5146_rset( 0x13, 0x80 );

    tvp5146_rset( 0xFE, 0x0F );

    tvp5146_rset( 0xB0, 0x00 );// D1

    tvp5146_rset( 0xB1, 0x10 );

    tvp5146_rset( 0xBE, 0x00 );

     //tvp5146_rset( 0xFE, 0x01);
     //tvp5146_rset( 0xB3, 0xE4);//e4

   tvp5146_rset( 0xB4, 0xE4 );

   tvp5146_rset( 0xB5, 0x00 );//((channel_D1-1)&0x7)

     //tvp5146_rset( 0xB5,0);

   tvp5146_rset( 0xB6, 0x1B );

   tvp5146_rset( 0xB7, 0x04 );

This is my initialization step, do not understand the wrong in there, who might help! 

  • Which device are you using, TVP5146 or TVP5158?

    BR,

    Steve

  •  HI Steve:

          The device is TVP5158, Function name does not modify! How to initialize TVP5158.

     Chen an

  • You seem to be writing to a reserved register E.g. register BEh is reserved.

    Why are you changing the chroma hue (register 14h)?

    Where did this code come from?

    Have you examined the command files which are included in the EVM software download?

    Is the DM configured to receive data in the same format as you are configuring the TVP to send? I don't know anything about the DM VIP so can't help with that unfortunately.

    BR,

    Steve

  •  

    Hi Steve:

        Steve: "Why are you changing the chroma hue (register 14h)?"
        chen an:  Now I use the default value!

        Steve: "Where did this code come from?"
        chen an: Code from dm6446 initial TVP5158, rewritten come from linux! 

        Steve: "Have you examined the command files which are included in the EVM software download?"
        chen an:TVP5158 connection the i2c of dm6437,  i2c is normal and the frequency is right.Because this drive is successful initial tvp5150.

               

    #define OSA_SOK  0
    #define TVP5146_I2C_ADDR 0x58

    Uint8 tvp5146_rget( Uint8 regnum )
    {
        Uint8 cmd[2];

        cmd[0] = regnum;    // 8-bit Register Address
        cmd[1] = 0;         // 8-bit Register Data

        EVMDM6437_I2C_write( TVP5146_I2C_ADDR, cmd, 1 );
        EVMDM6437_I2C_read ( TVP5146_I2C_ADDR, cmd, 1 );

        return cmd[0];
    }

    int DRV_i2cRead8 (Uint8 *reg, Uint8 *value, Uint8 count)
    {
        int i;
        for(i=0;i<count;++i)
        {
           value[i] = tvp5146_rget(reg[i]);
        }
    }

     

    void tvp5146_rset( Uint8 regnum, Uint8 regval )
    {
        Uint8 cmd[2];
        cmd[0] = regnum;    // 8-bit Register Address
        cmd[1] = regval;    // 8-bit Register Data

        EVMDM6437_I2C_write( TVP5146_I2C_ADDR, cmd, 2 );
        _waitusec( 2000 );
    }

    int DRV_i2cWrite8 (Uint8 *reg, Uint8 *value, Uint8 count)
    {

        int i;
        for(i=0;i<count;++i)
        {
           tvp5146_rset(reg[i],value[i]);
        }

        return 0;

    }

    int TVP5158_selectWrite(Uint8 value)
    {

       Uint8 regAddr[1];
       Uint8 regVal[1];
      Uint32 k;

       k=0;

       regAddr[k] = 0xFE;
       regVal[k]  = value;
       k++;

       return DRV_i2cWrite8(regAddr, regVal, k);

    }

    int TVP5158_vbusWrite(Uint32 vbus_addr, Uint8 val, Uint8 len)
    {
     int k;
     Uint8 regAddr[4];
     Uint8 regVal[4];

       k=0;

       regAddr[k] = 0xE8;
       regVal[k]  = (Uint8)((vbus_addr>>0) & 0xFF);
     k++;

       regAddr[k] = 0xE9;
       regVal[k]  = (Uint8)((vbus_addr>>8) & 0xFF);
     k++;

       regAddr[k] = 0xEA;
       regVal[k]  = (Uint8)((vbus_addr>>16) & 0xFF);
     k++;

       if(len)
        {
         regAddr[k] = 0xE0;
         regVal[k]  = val;
       k++;
       }

       return DRV_i2cWrite8(regAddr, regVal, k);
    }

    int TVP5158_softReset()
    {
      int status=OSA_SOK;

     Uint8 regAddr[8];
     Uint8 regVal[8];
       Uint32 k;
       Uint8 vbusStatus; 

       status = TVP5158_selectWrite(0xF);

       if(status!=OSA_SOK)
            goto error_exit;

       k=0;

       regAddr[k] = 0xE8;
       regVal[k] = 0x60;
       k++;

       regAddr[k] = 0xE9;
       regVal[k] = 0x00;
       k++;

       regAddr[k] = 0xEA;
       regVal[k] = 0xB0;
       k++;

       DRV_i2cWrite8(regAddr, regVal, k);

       k=0;

       regAddr[k] = 0xE0;
       regVal[k] = 0;
       k++;

       status = DRV_i2cRead8(regAddr, regVal, k);

       if(status!=OSA_SOK)
         goto error_exit;

       vbusStatus = regVal[0] | 1;

       status = TVP5158_vbusWrite(0xB00060, vbusStatus, 1);

       if(status!=OSA_SOK)
         goto error_exit;

       vbusStatus &= ~(0x1);

       status = TVP5158_vbusWrite(0xB00060, vbusStatus, 1);

       if(status!=OSA_SOK)
         goto error_exit;

       _waitusec(300);
     
     error_exit:
     //if(status!=OSA_SOK)
     //  OSA_ERROR("I2C");

       return status;
    }

    void tvp5158_init( Uint32 ntsc_pal_mode, Uint32 input_mode,Uint8 channel_D1  )
    {
     Uint8 rom_version, chipid_msb, chipid_lsb, data;
     Int32 j;
     Uint16 port[4]={0,1,2,3};

     //tvp5146_rset( 0x1A, 0x0F);
     //_waitusec( 2000 );
     //tvp5146_rset( 0x1A, 0x00);
     //_waitusec( 2000 );

       /*
          Y =  0.299*R + 0.587*G + 0.114*B;
           U = -0.147*R - 0.289*G + 0.436*B;
           V =  0.615*R - 0.515*G - 0.100*B;
        */
         rom_version = tvp5146_rget( 0x04 );
         chipid_msb  = tvp5146_rget( 0x08 );
         chipid_lsb  = tvp5146_rget( 0x09 ); 
         TVP5158_softReset(); 
         _waitusec( 1000 );     

       //tvp5146_rset( 0x14, 0xe4 );
     //tvp5146_rset( 0x13, 80 );
     //tvp5146_rset( 0x13, 0x80);
    #if 0
     for(j=0;j<4;j++)
     {   
         /*port_D*/   /*port_C*/   /*port_B*/   /*port_A*/   
         data=(port[0]<<6)|(port[1]<<4)|(port[2]<<2)|port[3];//OUT port_A
               
          tvp5146_rset( 0xB3, data );
         //tvp5146_rset( 0x14, 0xe4 );
         //tvp5146_rset( 0x13, 0x58 );
         ExChange(&port[0],&port[j]);
     }
    #endif

    #if 0      
       tvp5146_rset( 0xFE, 0x0F);
      tvp5146_rset( 0xB0, 0xE3);//4CH_CIF_PLUS_D1
       tvp5146_rset( 0xB1, 0x11);
       //tvp5146_rset( 0xB2, 0x25);

       tvp5146_rset( 0xFE, 0x01);
       tvp5146_rset( 0xB3, 0xE4);//e4
       tvp5146_rset( 0xB4, 0xE4);
       tvp5146_rset( 0xB5, ((channel_D1-1)&0x7));
       //tvp5146_rset( 0xB6, 0x1B);
       //tvp5146_rset( 0xB7, 0x04);
       tvp5146_rset( 0xB6, 0xE3);
       tvp5146_rset( 0xB7, 0x14);
       //tvp5146_rset( 0xB6, 0xc6);
       //tvp5146_rset( 0xB7, 0x19);

       tvp5146_rset( 0xB2, 0x25);
    #else
        tvp5146_rset( 0xFE, 0x0F);
        tvp5146_rset( 0xB0, 0x00);//D1
        tvp5146_rset( 0xB1, 0x10);
        tvp5146_rset( 0xBE, 0x00);
        tvp5146_rset( 0xB4, 0xE4);
        tvp5146_rset( 0xB5, 0x00);
        tvp5146_rset( 0xB6, 0x1B);
        tvp5146_rset( 0xB7, 0x04); 
    #endif
     
       _waitusec( 2000 );
    }

     This is my dm6347 initialization tvp5158 procedure,but did not successfully initialized TVP5158.  
     Could You  give me some advice or reference examples?
     
     chen an
     

  • Chen an,

    When I said "Have you examined the command files which are included in the EVM software download?" I really meant for you to download the EVM software and look for the example ".cmd" files for various modes. These files are simply text files which contain a list of I2C commands necessary to configure to various mode. I suggest starting with these files as an example of what is necessary to configure the TVP5158.

    BR,

    Steve