Other Parts Discussed in Thread: ADS124S08
程序如下。设置寄存器ADC_AUXCN时,可正常设置,并且可以读取到写入的值是0x2A,但是用万用表测量2K电阻两端,无电压,说明无电流输出,经测量,IB2管脚对地电阻是2.1K。电路如下图所示。
不知道是不是还有个什么启动设置?
/*ADC_AUXCN:ADC Auxiliary Control(Address 0x12)
使用内部时钟,1000μA电流
要使用内部时钟,请将CLK_EXT_DET设置为1,CLK_SEL设置为0
*/
for(i=0; i<10; i++) //最多设置10次
{
HAL_GPIO_WritePin(SPI1_NSS_GPIO_Port, SPI1_NSS_Pin, GPIO_PIN_RESET);
command[0] = 0x10; // 0x10:write address,0x90:Read Address
command[1] = 0x01; // Upper Address Byte:0x1
command[2] = 0x02;
/* bit 7=0: Reserved;
bit6 RESET_SYSCAL=0:Preserved even when "REG_AND_RST"=0xC3;
bit5 CLK_EXT_DET=1: default, external clock is operational;
bit4 CLK_SEL=0: default, select internal clock
bit[3:0] RTD_CUR_SEL = 0xA: 1000μA
*/
command[3] = 0x2A;
HAL_SPI_Transmit(&hspi1,&command[0],4,100);
HAL_GPIO_WritePin(SPI1_NSS_GPIO_Port, SPI1_NSS_Pin, GPIO_PIN_SET);
j=100;
while(j--);
//读取设置的值,看下是否符合预期,测试是通过的
HAL_GPIO_WritePin(SPI1_NSS_GPIO_Port, SPI1_NSS_Pin, GPIO_PIN_RESET);
command[0] = 0x10; // 0x10:write address,0x90:Read Address
command[1] = 0x01; // Upper Address Byte:0x1
command[2] = 0x82;
HAL_SPI_Transmit(&hspi1,&command[0],3,100);
HAL_SPI_Receive(&hspi1,&calibration[0],1,100);
HAL_GPIO_WritePin(SPI1_NSS_GPIO_Port, SPI1_NSS_Pin, GPIO_PIN_SET);
if((calibration[0] & 0x7F) == 0x2A)
{
break;
i = 10; //经添加break语句测试,第一个循环即可校准完成
}
else if (i == 9)
{
//报错,不能初始化AUXCN,地址0x12
}
}