mcu_arm9 发表于 2012-4-28 12:27:47

关于S52驱动TVP5150视频解码器的问题,I2C写入出了问题

#include "REG52.h"
#include <intrins.h>
#define add 0xBA>>1

sbit SDA = P3^4;
sbit SCL = P3^3;


void start();
void stop();
bit shout(unsigned char write_data);
void write_byte(unsigned char write_com, unsigned char write_data);
void delayms(unsigned char ms);
void delayus(unsigned char us);

main(void)
{
        SDA = 1;
        SCL = 1;
    P1 =0XFF;

    write_byte(0x00, 0x00);
    write_byte(0x03, 0x09);
    //P1 = shout;
        while(1)
        {
      ;
        }         
}

void start()
// 开始位
{
        SDA = 1;
        SCL = 1;
        _nop_();
        _nop_();
        SDA = 0;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        SCL = 0;
}

void stop()
// 停止位
{
        SDA = 0;
        _nop_();
        _nop_();
        SCL = 1;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        SDA = 1;
}


bit shout(unsigned char write_data)
// 从MCU移出数据到5150
{
        unsigned char i;
        bit ack_bit;
        for(i = 0; i < 8; i++)                // 循环移入8个位
        {
                SDA = (bit)(write_data & 0x80);
                _nop_();
      _nop_();
                SCL = 1;
                _nop_();
                _nop_();
                SCL = 0;
                write_data <<= 1;
        }
        SDA = 1;                        // 读取应答
        _nop_();
        _nop_();
        SCL = 1;
        _nop_();
        _nop_();
        _nop_();
        _nop_();
        ack_bit = SDA;
        SCL = 0;
        return ack_bit;                        // 返回AT24Cxx应答位
}

void write_byte(unsigned char write_com, unsigned char write_data)
// 在指定地址addr处写入数据write_data
{
        start();
        shout(add);
        shout(write_com);
        shout(write_data);
    delayus(1);         //122us左右
        stop();
        delayms(10);                // 写入周期
}


void delayms(unsigned char ms)       
// 延时子程序
{
        unsigned char i;
        while(ms--)
        {
                for(i = 0; i < 120; i++);
        }
}

void delayus(unsigned char us)       
// 延时子程序
{
        unsigned char i;
        while(us--)
        {
                for(i = 0; i < 10; i++);
        }
}


这是程序,我用逻辑分析器可以看到S52所输出的I2C波行,如图1和如图2,频率在51KHZ左右,I2C的输出。现在问题是TVP5150无反应,所有输出脚都无信号。
    write_byte(0x00, 0x00);   这两个是配置的,我用逻辑分析仪直接测试的SCLK脚,无信号输出(其它脚信号都无信号)。
    write_byte(0x03, 0x09);

图1 write_byte(0x00, 0x00); :


图2 write_byte(0x03, 0x09):


现在不知道问题出在什么地方,不请各位帮一下忙,如果是I2C有问题看能不能给个I2C的程序,谢谢了。

wszyjsw2 发表于 2012-4-28 13:21:51

本帖最后由 wszyjsw2 于 2012-4-28 13:27 编辑

居然 还有视频的解码器芯片 第一次听说 还是51驱动的 ,能解MP4和AVI的文件吗?

mcu_arm9 发表于 2012-4-28 14:01:08

是解CVBS信号的,有的叫AV信号,就是一般监控摄像机出来的图像,然后解成BT656的格式输出来,然后过DSP或者CPU处理。现在我只是用单片机来驱动他,看他能不能正常工作,单片机是不能处理这么复杂的信号的。
页: [1]
查看完整版本: 关于S52驱动TVP5150视频解码器的问题,I2C写入出了问题