FSL_TICS_Fiona 发表于 2014-1-11 17:22 
上电与复位执行的是同一个程序入口,如果上电工作不正常,但是复位可以,可能有发生了数据调电丢失。请检查 ...
请问这个应该从哪里去看呢?貌似没有什么全局变量和常数呀
附带上我的程序吧:
这里放在主函数里的程序:
sccb_init();
sccb_regWrite(0x42,0x11,0x03); //地址0X11-中断四分频(640*240) PCLK:166ns HREF:254.6us VSYN:133.6ms
sccb_regWrite(0x42,0x14,0x24); //地址0X14-QVGA(320*120) PCLK:332ns HREF:509.6us VSYN:133.6ms
sccb_regWrite(0x42,0x28,0x20); //地址0X28-连续采集模式(320*240) PCLK:666ns HREF:509.6us VSYN:133.6ms
sccb_wait();
函数放在了其他的文件里:
void sccb_init(void)
{
PORTA_PCR12 = PORT_PCR_MUX(1);
PORTA_PCR13 = PORT_PCR_MUX(1);
}
/************************************************************************
*
* 函数名称:sccb_wait
* 功能说明:SCCB延时,不应太小
* 参数说明:无
* 函数返回:无
*
*************************************************************************/
void sccb_wait(void)
{
uint_16 i;
for( i=0; i<100; i++)
{
asm ("nop");
}
}
/************************************************************************
*
* 函数名称:sccb_start
* 功能说明:SCCB启动位
* 参数说明:无
* 函数返回:无
*
*************************************************************************/
void sccb_start(void)
{
SCL_OUT;
SDA_OUT;
SDA_HIGH;
//sccb_wait();
SCL_HIGH;
sccb_wait();
SDA_LOW;
sccb_wait();
SCL_LOW;
}
/************************************************************************
*
* 函数名称:sccb_stop
* 功能说明:SCCB停止位
* 参数说明:无
* 函数返回:无
*
*************************************************************************/
void sccb_stop(void)
{
SCL_OUT;
SDA_OUT;
SDA_LOW;
sccb_wait();
SCL_HIGH;
sccb_wait();
SDA_HIGH;
sccb_wait();
}
/************************************************************************
*
* 函数名称:sccb_sendByte
* 功能说明:在SCCB总线上发送一个字节
* 参数说明:data 要发送的字节内容
* 函数返回:无
*
*************************************************************************/
uint_8 sccb_sendByte(uint_8 data)
{
uint_8 i;
uint_8 ack;
SDA_OUT;
for( i=0; i<8; i++)
{
if(data & 0x80)
SDA_HIGH;
else
SDA_LOW;
data <<= 1;
sccb_wait();
SCL_HIGH;
sccb_wait();
SCL_LOW;
sccb_wait();
}
SDA_HIGH;
SDA_IN;
sccb_wait();
SCL_HIGH;
sccb_wait();
ack = SDA_DATA;
SCL_LOW;
sccb_wait();
return ack;
}
/************************************************************************
*
* 函数名称:sccb_regWrite
* 功能说明:通过SCCB总线向指定设备的指定地址发送指定内容
* 参数说明:device---设备号 读写有区别
* address---写数据的寄存器
* data---写的内容
* 函数返回:ack=1未收到应答(失败) ack=0收到应答(成功)
*
*************************************************************************/
void sccb_regWrite(uint_8 device,uint_8 address,uint_8 data)
{
uint_8 i;
uint_8 ack;
for( i=0; i<20; i++)
{
sccb_start();
ack = sccb_sendByte(device);
if( ack == 1 )
{
// sccb_stop();
continue;
}
ack = sccb_sendByte(address);
if( ack == 1 )
{
// sccb_stop();
continue;
}
ack = sccb_sendByte(data);
if( ack == 1 )
{
// sccb_stop();
continue;
}
sccb_stop();
if( ack == 0 ) break;
}
}
之后就是头文件:
void sccb_init(void); //初始化SCCB端口为GPIO
void sccb_wait(void); //SCCB时序延时
void sccb_start(void); //起始标志
void sccb_stop(void); //停止标志
uint_8 sccb_sendByte(uint_8 data);
void sccb_regWrite(uint_8 device,uint_8 address,uint_8 data);
//--GPIO_DDR_1bit(PORTx,n,ddr)--//
#define SCL_OUT GPIOA_PDDR|= (1<<12) //SCL-PA12设置为输出端口
#define SDA_OUT GPIOA_PDDR|= (1<<13) //SDA-PA13设置为输出端口
#define SDA_IN GPIOA_PDDR &= ~(1<<13) //SDA-PA13设置为输入端口
//--GPIO_SET_1bit(PORTx,n,data)--//
#define SCL_HIGH GPIOA_PDOR|= (1<<12)
#define SCL_LOW GPIOA_PDOR &= ~(1<<12)
#define SDA_HIGH GPIOA_PDOR|= (1<<13)
#define SDA_LOW GPIOA_PDOR &= ~(1<<13)
#define SDA_DATA (GPIOA_PDIR >> 13) & 1
|