如题,通过csl库提供的程序,可以正确设置和读写PAGE0页的数据,但是读取PAGE4页上的寄存器值都为0,很奇怪,数据手册好像也没有说读取PAGE4与读取其他页面上的寄存器有什么不同,不知道有没有谁遇到同样问题,在线等!!!
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.
你好,
是的,但是你要使用时还需要写入对应寄存器里面相应的系数值,才能得到你想要的滤波器参数。建议你下载ADC3101的评估软件GUI,用其生成你想要的滤波器参数再写入到对应的寄存器里面去。
软件下载地址:http://www.ti.com/tool/tlv320adc3101evm-k
谢谢!
您好:
PAGE0,PAGE1 可以正确读写,但是PAGE4好像只能读取register0,指示当前处于第4页,读取其他寄存器一直为0,下面是读写函数,底层I2C读写驱动是通过csl库
/*
*
* ADC3101_rget( addr, regnum, *regval )
*
* Return value of codec register regnum
*
*/
Int16 ADC3101_rget( Uint16 addr, Uint16 regnum, Uint16* regval )
{
Int16 retcode = 0;
Uint16 cmd[2];
cmd[0] = regnum & 0x007F; // 7-bit Device Register
cmd[1] = 0;
retcode |= EZDSP5535_I2C_write( addr, cmd, 1 );
retcode |= EZDSP5535_I2C_read( addr, cmd, 1 );
*regval = cmd[0];
EZDSP5535_wait( 10 );
return retcode;
}
/*
*
* ADC3101_rset( addr, regnum, regval )
*
* Set codec register regnum to value regval
*
*/
Int16 ADC3101_rset( Uint16 addr, Uint16 regnum, Uint16 regval )
{
Uint16 cmd[2];
cmd[0] = regnum & 0x007F; // 7-bit Device Register
cmd[1] = regval; // 8-bit Register Data
EZDSP5535_waitusec( 300 );
return EZDSP5535_I2C_write( addr, cmd, 2 );
}
==========================================================
底层I2C驱动
==========================================================
*
* EZDSP5535_I2C_read( i2c_addr, data, len )
*
* I2C read in Master mode: Reads from I2c device with address
* "i2c_addr" and stores to the location of "data" for length "len".
*
* Uint16 i2c_addr <- I2C slave address
* Uint16* data <- I2C data ptr
* Uint16 len <- # of bytes to write
*/
Int16 EZDSP5535_I2C_read( Uint16 i2c_addr, Uint16* data, Uint16 len )
{
Uint16 startStop = ((CSL_I2C_START) | (CSL_I2C_STOP));
CSL_Status status;
/* I2C Read */
status = I2C_read(data, len, i2c_addr,
TRUE, startStop, CSL_I2C_MAX_TIMEOUT, FALSE);
return status;
}
/*
* EZDSP5535_I2C_write( i2c_addr, data, len )
*
* I2C write in Master mode: Writes to I2c device with address
* "i2c_addr" from the location of "data" for length "len".
*
* Uint16 i2c_addr <- I2C slave address
* Uint16* data <- I2C data ptr
* Uint16 len <- # of bytes to write
*/
Int16 EZDSP5535_I2C_write( Uint16 i2c_addr, Uint16* data, Uint16 len )
{
Uint16 startStop = ((CSL_I2C_START) | (CSL_I2C_STOP));
CSL_Status status;
/* I2C Write */
status = I2C_write(data, len, i2c_addr,
TRUE, startStop, CSL_I2C_MAX_TIMEOUT);
return status;
}
你设置0x00寄存器为0x04,选择Page4后,再回读一下该寄存器,看看是否是写入的值?
在配置完页寄存器后,即写0x00寄存器为0x04,读其他寄存器时加一点延时10~100ms看看有没有正确数据返回。
“datasheet上关于PAGE4的寄存器介绍如下图,所谓的滤波器系数需要连续编程2个寄存器具体是什么意思?”
每个系数,例如C1,是由两个字节组成的,高八位和低八位。写入时,这连个系数不能断开写,要先写高八位,紧接着写低八位。