Help! TDC gp21 SPI not working
Our team is trying to design a ultrasound imaging system which involves using the TDC-GP22 for the transducer.
We designed the transducer board our self.
Right now, We are trying to use Beagle-board to establish the communication with the transducer board through SPI interface.
Based on the information from the data sheet and the info here(http://www.ccsinfo.com/forum/viewtopic.php?p=160435)
I coded the program myself, I used a GPIO to control the SSN line ,so it will be set to low before writing/reading the Data and set high after write/read.
Same goes for RESET, I set RESET it to low before writing/reading the Data and set high after the write/read.
I also confirmed the CLK/MOSI on the scope and so we know that we are sending the right Data. However, We failed to read anything back from the chip. We tested the MISO with the scope and it shows the read-back pulse but it is very weak.(200mv)
So we can not read anything back on the beagle-board,b/c the signal is too weak, We tried to re-solder some part and fix some potential short-circuit. but It did not work.
Does anyone know why is this happening.
It would be great if We could get some helps here.
Please advise.
Thanks
I suggest two explanations:
- You don't manage to perform a read instruction (wrong Opcode, wrong SPI mode, whatsoever). What you see is just crosstalk to the high impedance MISO line.
- You do read, but the MISO line is shorted.
Connecting a pull-up and pull-down resistor to the MISO line for test should allow to distinguish between both issues.
Hi FvM, Thanks for your reply.
We did tested MISO line with a pull-up resistor and we got a read-back pulse about 400mv.
Also,We measure the resistance between the MISO line to the ground and confirmed that it is not shorted.
Since We are running test code(SPI mode 1), We only did the easiest writing like sending 0x50 to power on the chip, writing to the register 0/1 with (0x80,0x430B6812), (0x81,0x21444512)
Here is our code to write to the registor
static void transfer(int fd,uint8_t opcode, uint32_t config_reg_data,int gpio_fd)
{
Clear_GPIO146(gpio_fd);//set reset pin to 0
Clear_SS(gpio_fd); // set SSN pin to 0
int ret;
uint8_t Data_Byte_Lo=config_reg_data;
uint8_t Data_Byte_Mid1=config_reg_data>>8;
uint8_t Data_Byte_Mid2=config_reg_data>>16;
uint8_t Data_Byte_Hi=config_reg_data>>24;
uint8_t tx[] ={opcode,Data_Byte_Hi,Data_Byte_Mid2,Data_Byte_Mid1,Data_Byte_Lo,};
uint8_t rx[ARRAY_SIZE(tx)] = {0, };struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)tx, .rx_buf = (unsigned long)rx, .len = ARRAY_SIZE(tx), .delay_usecs = 100, .speed_hz = speed, .bits_per_word = bits,};
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);if (ret < 1) pabort("can't send spi message");
Set_GPIO146(gpio_fd);//set reset pin back to 1
Set_SS(gpio_fd); //set SSN pin back to 1
}
static uint32_t Read_4_bytes(int fd,uint8_t opcode,int gpio_fd)
{
uint32_t Read_result=0;
uint8_t temp;
Clear_GPIO146(gpio_fd);//set reset pin to 0
Clear_SS(gpio_fd); // set SSN pin to 0
temp=Send_1byte(fd,opcode,gpio_fd); //send the opcode 0x81/0x80
temp=Sent_dummy(fd); //send dummy 0xFF
Read_result |=temp;//read
Read_result =Read_result<<8;
printf("the first 8bit read is %.2X\n",temp);
temp=Sent_dummy(fd);
Read_result |=temp;//read
Read_result =Read_result<<8;
printf("the second 8bit read is %.2X\n",temp);
temp=Sent_dummy(fd);
Read_result |=temp;//read
Read_result =Read_result<<8;
printf("the third 8bit read is %.2X\n",temp);
temp=Sent_dummy(fd);
Read_result |=temp;//read
printf("the last 8bit read is %.2X\n",temp);
Set_GPIO146(gpio_fd);
Set_SS(gpio_fd);
Set_GPIO146(gpio_fd);//set reset pin back to 1
Set_SS(gpio_fd); //set SSN pin back to 1
return Read_result;
}
Hi Fvm, I fixed the problem.
The problem is that T am not supposed to set the reset pin to 0 before every write/read.
I only need to set it low at the beginning of the program once and keep it high.
Thanks you.
SPI busses stink. Even big fancy chip vendors implement them willy nilly. I have one chip that we have to bit bang twice just to get the registers to stick. Ask their app engineers for actual code, and a description of any flukes
also, keep ur line lengths short! Ringing is not allowed.
