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.
from timing description of datasheet, i can't find how to read/write CFR register and read ADC data. Is there any sample code for ADS8239?
(1) Is it necessary to send read ADC data command every time? and if send cmd and read data is in the same CS/FS valid period?
(2) why the SDO oupput is so low(about 1.5V, My Vdd is 5V) when i execute the test functions below? Is there any hardware problem?
/*************ADS8329 AD_Converter********************/
unsigned int ads8329_get_data(void)
{
unsigned char i;
unsigned int x = 0;
ADC_CS = 0;
ADC_CLK = 0;
for(i=0; i<16; i++)
{
ADC_CLK = 0;
ads8329_delay(T_DELAY);
x<<=1;
if(ADC_SDO == 1)
{
x++;
}
ADC_CLK = 1;
ads8329_delay(T_DELAY);
}
ADC_CS = 1;
x &= 0xffff;
return (x);
}
Thanks a lot
1. 1MHz 时钟问题,没太注意,需要确认一下。
2. 每次读数时,都要在SDI上写入1101b,这个意思是CS 拉低后,先在SDI上写4个Clk ,也就是1101(还是16个clk?),这个时候CS 不拉高,继续开始发16个clk读数据吗?这次读取到的数据是上次转换的数据吗?
unsigned int ads8329_get_data(void)
{
unsigned char i;
unsigned int x = 0;
ADC_CS = 0;
ADC_CLK = 0;
for(i=0; i<4; i++) //send read command or for(i=0; i<16; i++)
{
ADC_CLK = 0;
ads8329_delay(T_DELAY);
ADC_SDI = 0xD>>(3-i)& 0x1; //ADC_SDI = 0xD000>>(15-i)& 0x1;
ads8329_delay(T_DELAY);
ADC_CLK = 1;
}
//这儿CS需要变化吗?
for(i=0; i<16; i++)
{
ads8329_delay(T_DELAY);
ADC_CLK = 0;
ads8329_delay(T_DELAY);
x<<=1;
if(ADC_SDO == 1)
{
x++;
}
ADC_CLK = 1;
}
ADC_CS = 1;
x &= 0xffff;
return (x);
}
3. 想使用#INT输出到处理器,需要修改内部寄存器,内部寄存器的读写方式跟读数据是一样的吗?默认是自动trigger模式吗?
谢谢!
代码貌似有问题。不知你用的是哪款MCU,但推断时钟可能达不到1MHz.
程序要求,在读取数据的16个clk中,前四个clk要向SDI写入1101b,是与读前四个数据同时进行的。而不是先写1101b,再读16个数据。
请认真阅读datasheet中12-14页中的时序图,严格按时序图写程序。