Hi,
I am using TUSS4470 ultrasonic sensor for measuring distance but I couldn't manage to do that. This my init values
I am generating 16 pulses with 40kHz frequency on TUSS4470 IO2 pin.
This is my schematic that I use. I am powering TUSS470 with 12V supply.
This is the write and read functions that I use and when I read the status register I get 0x08 value as return and as a datasheet this is the correct value.
void tuss4470_spi_read_reg(uint8_t register_value) {
memset(tx_buf,0x00,2);
memset(rx_buf,0x00,2);
register_value = 0x80 + ((register_value & 0x3F) << 1);
tx_buf[0] = register_value;
tx_buf[1] = 0x00;
HAL_GPIO_WritePin(NSS_PIN_GPIO_Port, NSS_PIN_Pin, GPIO_PIN_RESET);
HAL_Delay(15);
HAL_SPI_TransmitReceive(&hspi2, tx_buf,rx_buf, 2, 100);
HAL_GPIO_WritePin(NSS_PIN_GPIO_Port, NSS_PIN_Pin, GPIO_PIN_SET);
HAL_Delay(20);
}
void tuss4470_spi_write_reg(uint8_t register_value, uint8_t data_value) {
memset(tx_buf,0x00,2);
memset(rx_buf,0x00,2);
register_value = (register_value & 0x3F) << 1;
register_value |= tuss44x0_parity(®ister_value); // apply parity bit
tx_buf[0] = register_value;
tx_buf[1] = data_value;
HAL_GPIO_WritePin(NSS_PIN_GPIO_Port, NSS_PIN_Pin, GPIO_PIN_RESET);
HAL_Delay(15);
HAL_SPI_TransmitReceive(&hspi2, tx_buf,rx_buf, 2, 100);
HAL_GPIO_WritePin(NSS_PIN_GPIO_Port, NSS_PIN_Pin, GPIO_PIN_SET);
//HAL_Delay(20);
}
and my main looks like this I use IOMODE 0 and I triggered CMD_TRIGGER bit.
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_SPI2_Init();
MX_TIM3_Init();
MX_TIM21_Init();
MX_ADC_Init();
HAL_GPIO_WritePin(BOOST_EN_GPIO_Port, BOOST_EN_Pin, GPIO_PIN_SET);
HAL_Delay(1000);
HAL_ADC_Start(&hadc);
chip_id = get_chip_id();
HAL_TIM_Base_Start(&htim21);
tuss4470_init();
status = get_status();
HAL_TIM_IC_Start_IT(&htim3, TIM_CHANNEL_3);
HAL_Delay(1000);
status = get_status();
while (1)
{
tuss4470_spi_write_reg(TOF_CONFIG, 0x00);
delay_us(11);
tuss4470_spi_write_reg(TOF_CONFIG, 0x01);
delay_us(11);
generate_pulses();
tuss4470_spi_write_reg(TOF_CONFIG, 0x00);
HAL_Delay(100);
}
This is the signal when I read the OUTA pin. It is not changing at all when I changing the position of ultrasonic transducer .
This is the signal when I read the OUT3 pin. This signal isn't changing either.
These signals only change when I touch the ultrasonic transducer and It looks like this when I touched it or pressed it.
I tried to put 100 ohm resistor between OUTA and OUTB pin. Signals are changed but they still steady. This is the OUTA pin signal after when I put 100 ohm resistor.
Any help would be so appreciated. What do I do wrong? Is it the init function values or do I use wrong ultrasonic transducer? These signals that I read is the signals that I should read?
Best regards.