AD7147
Production
The AD7147 CapTouch™ controller is designed for use with capacitance sensors implementing functions such as buttons, scroll bars, and wheels. The sensors...
Datasheet
AD7147 on Analog.com
Using a STM32F103C8T6 as mcu, my MISO remains low while MISO and CLK runs correctly, i wonder if its becuase that my Vdrive connected to 3.3V. Anyone who have encountered with this? Please help me!!!!!!!!
Hi Marksj , Vdrive functional range is up to 3.6V, you mention MISO twice above, which signal is it that is not working ? Please share full AD7147 product code, schematic diagram and scope capture of SPI signals.
Regards,
Maurice.
Thank you for replying! Sorry for mistyping, its MOSI working normally and MISO no response. You mentioned that "Vdrive functional range is up to 3.6V", however my MISO back to work correcly when I charged Vdrive 1.77V, I'm so confused. My commuication code are as below. void SPI_Delay(unsigned char i)
{
i = 50;
while(i--);
}
unsigned short SPI_ReadShort()
{
unsigned short data = 0;
unsigned char bits = 0;
for(bits=0;bits<16;bits++){
SCK_L();
SPI_Delay(30);
SCK_H();
SPI_Delay(30);
data = data<<1;
data += MISO();
}
SCK_H();
//HAL_SPI_Receive(&hspi1, (unsigned char*)&data, 1, 50);
return data;
}
void SPI_WriteShort(unsigned short data)
{
unsigned char bits = 0;
for(bits=0;bits<16;bits++){
SCK_L();
SPI_Delay(50);
if(data&0x8000){
MOSI_H();
}else{
MOSI_L();
}
data = data<<1;
SCK_H();
SPI_Delay(50);
}
MOSI_L();
//HAL_SPI_Transmit(&hspi1, (unsigned char*)&data, 1, 50);
}
/*
p35 figure51 读取单个寄存器
*/
void AD7147_SingleRead(unsigned short add, unsigned short *databuff)
{
unsigned short Txbuff[2] = {add+0xE400, 0xFFFF};
CS_ENABLE();
SPI_WriteShort(add+0xE400);
*databuff = SPI_ReadShort();
//HAL_SPI_TransmitReceive(&hspi1, (unsigned char*)Txbuff, (unsigned char*)databuff, 2, 50);
CS_DISABLE();
}
//写入单个寄存器
void AD7147_SingleWrite(unsigned short add, unsigned short data)
{
unsigned short addbuff[2] = {add+0xE000, data};
unsigned short databuff[2] = {0xFFFF, 0xFFFF};
CS_ENABLE();
SPI_WriteShort(add+0xE000);
SPI_WriteShort(data);
//HAL_SPI_TransmitReceive(&hspi1, (unsigned char*)&addbuff, (unsigned char*)databuff, 2, 50);
CS_DISABLE();
}
/*连续写入,size的单位是short*/
void AD7147_ContinuWrite(unsigned short add, unsigned short *data, unsigned short size)
{
unsigned short i;
CS_ENABLE();
SPI_WriteShort(add+0xE000);//E是控制命令 0是读/写位置0
for(i=0;i<size;i++){
SPI_WriteShort(data[i]);
}
CS_DISABLE();
}
//连续读取,size的单位是short
void AD7147_ContinuRead(unsigned short add, unsigned short *data, unsigned short size)
{
unsigned short i;
CS_ENABLE();
SPI_WriteShort(add+0xE400);//E是控制命令 4是读/写位置1
for(i=0;i<size;i++){
data[i] = SPI_ReadShort();
}
CS_DISABLE();
}
Can you share a schematic diagram, what is the voltage of Vcc ?
Can you share a schematic diagram, what is the voltage of Vcc ?