驱动程序可以写入后再读取寄存器的值,== 相等
通讯上是没问题,但读ad读到的都是16777215 不知道是哪里问题。
有没有例程可以参考以下
m15512461300@163.com 谢谢!
以下是我的部分代码:
voidCS1259B_Read_AinN(uint8_tch,uint32_t* voltage,uint8_tAinx){uint8_tWriteCh =0;switch(Ainx) {caseCS1259B_Ain1: WriteCh =0x20;break;caseCS1259B_Ain2: WriteCh =0x61;break;;caseCS1259B_Ain3: WriteCh =0x62;break;;caseCS1259B_Ain4: WriteCh =0x63;break;;caseCS1259B_Ain5: WriteCh =0x5C;break;;default:return; }SendDataToAddr(ch,ADDR_AFE_ADC0,WriteCh);SendDataToAddr(ch,ADDR_AFE_SYS,0x16); *voltage =ReadADC(ch);SendDataToAddr(ch,ADDR_AFE_SYS,0x10);delay_us(5); }
uint32_tReadADC(uint8_tCH){uint8_ttempH,tempM,tempL;startCS125x(CH);send1byte(ADDR_AFE_ADO);delay_us(800); tempH=read1byte();; tempM=read1byte(); tempL=read1byte();stopCS125x(CH);return((tempH<<16)|(tempM<<8)|(tempL)); }
void CS1259B_init(void) {ioSpi_Init();delay_ms(10);delay_ms(10);delay_ms(10); SendDataToAddr(1,ADDR_AFE_ADC1,0x80);delay_ms(10);delay_ms(10); SendDataToAddr(1,ADDR_AFE_ADC3,0x00);delay_ms(10); SendDataToAddr(1,ADDR_AFE_ADC4,0x41);delay_ms(10); SendDataToAddr(1,ADDR_AFE_ADC5,0x0![微信图片_20230926160840.png](//file1.elecfans.com/web2/M00/A6/30/wKgaomUSkeuAco8NAAHWQPa5Gqk087.png) 0);delay_ms(10);