This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PGA460: Unable to read echo detection results at 200KHz burst frequency

Part Number: PGA460

Tool/software:

I am currently debugging the PGA460 chip and have encountered the following issues. I hope you can assist me in resolving them. Thank you.Problem description is as follows:I am currently using a burst frequency of 200KHz to drive the ultrasonic sensor and have measured the echo:

I set the recording time to 8.196ms. When I send the command 0x5505 to read the measurement result, the returned data is: ox40 FF FF FF FF;I then send the command ox5507 to read the echo data, and there are several scenarios:

DP_MUX=0:

DP_MUX=3:

DP_MUX=4:

Question 1: When I read the measurement result, why does the returned content consist entirely of FFs? What does FF represent?

Question 2: When DP_MUX=4, the data seems normal, but when DP_MUX=3, after passing through the bandpass filter, the data appears abnormal. The parameters of the bandpass filter are set to 0xE1, 0x9F, 0xF9, 0xA5, 0x03, 0x2D. Are these parameter settings correct? If not, how should I set the correct parameters?

Question 3: Is Question 2 causing the abnormal measurement results? If not, where might the problem be?

  • Hello Jin,

    Thanks for posting to the sensors forum! I replied to your other post so please let me know if I can close that issue out since it seems you are also asking about the bandpass filter here.

    Let me help address your questions:

    1. When I read the measurement result, why does the returned content consist entirely of FFs? What does FF represent?
      1. The FF's represent that there is no result to provide. This essentially means that your signal echo did not meet the threshold you configured. If you are confident that you are getting the return echo at the expected time based on your target I would review your threshold configurations to ensure that they are set at the right times and levels. When the threshold is not the met the device simply reports FFs for all the fields.
    2. When DP_MUX=4, the data seems normal, but when DP_MUX=3, after passing through the bandpass filter, the data appears abnormal. The parameters of the bandpass filter are set to 0xE1, 0x9F, 0xF9, 0xA5, 0x03, 0x2D. Are these parameter settings correct? If not, how should I set the correct parameters?
      1. The recommended settings would be 0x8B 0x4D 0xF3 0x72 0x06 0x47, this is register 0x41-0x46.
    3. Is Question 2 causing the abnormal measurement results? If not, where might the problem be?
      1. Its possible it may be the thresholding, at least this is a common issue for most users. The BPF settings were very different so this could been an issue.

    I hope this helps!

    Best,

    Isaac

  • Thank you for your reply!

    Following your recommended BPF (0x8B, 0x4D, 0xF3, 0x72, 0x06, 0x47) parameters, there was no significant improvement after writing them. When sending the 0x55 05 command to read the measurement results, objects are still not detected, and the returned data remains: 40 FF FF FF FF;By reading the echo data, some of the data is as follows:

    DP_MUX = 2:

    DP_MUX = 3:

     The thresholding setting:

    P1_GAIN_CTRL0x08

    Question 1: I would like to know if the new BPF parameters are working, and how are the BPF parameters calculated?

    Question 2: When DP_MUX=3, is the echo data read out normal?

    Question 3: When DP_MUX=2, is the echo data read out normal? Also, are there any registers related to the rectifier that need to be configured?

    Question 4: Is the current thresholding  setting appropriate? If it is appropriate, what other reasons could cause the failure to detect objects?

  • Hello Jin,

    I actually made a mistake on the bandpass filter coefficients the values should be 0xDD 0xBA 0xF9 0xA5 0x03 0x2D, apologies on the incorrect values. Regarding your question #1 we have a table with the values precalculated for different frequencies with different options depending on the selected bandwidth for the bandpass filter. You can find this table in the PGA460 GUI under the file menu if you would like to see this table.

    Are you disabling the DP_MUX before you run the command 0x05? I just thought about this but if the DP_MUX is not disabled (returned to 0x00) then the results will continue to be 0xFF. Using the test mode sends the data via another path so the data never reaches the threshold map in order to obtain a UMR that can be sent out.

    Best,

    Isaac

  • I have updated the BPF parameters (0xDD 0xBA 0xF9 0xA5 0x03) and set DP_MUX = 0, DATADUMP_EN=0, but I still cannot detect objects when reading the measurement results.Then I re-read the echo data, and here is some of the content I read:

    DP_MUX = 2:

    DP_MUX = 3:

    I hope to further analyze the cause of the issue, thank you.Additionally, here is my code, I hope you can check if there are any parameter settings errors:

    /* USER CODE BEGIN Header */
    /**
      ******************************************************************************
      * @file           : main.c
      * @brief          : Main program body
      ******************************************************************************
      * @attention
      *
      * Copyright (c) 2025 STMicroelectronics.
      * All rights reserved.
      *
      * This software is licensed under terms that can be found in the LICENSE file
      * in the root directory of this software component.
      * If no LICENSE file comes with this software, it is provided AS-IS.
      *
      ******************************************************************************
      */
    /* USER CODE END Header */
    /* Includes ------------------------------------------------------------------*/
    #include "main.h"
    #include "dma.h"
    #include "usart.h"
    #include "gpio.h"
    
    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */
    
    /* USER CODE END Includes */
    
    /* Private typedef -----------------------------------------------------------*/
    /* USER CODE BEGIN PTD */
    
    /* USER CODE END PTD */
    
    /* Private define ------------------------------------------------------------*/
    /* USER CODE BEGIN PD */
    /* USER CODE END PD */
    
    /* Private macro -------------------------------------------------------------*/
    /* USER CODE BEGIN PM */
    
    /* USER CODE END PM */
    
    /* Private variables ---------------------------------------------------------*/
    
    /* USER CODE BEGIN PV */
    
    /* USER CODE END PV */
    
    /* Private function prototypes -----------------------------------------------*/
    void SystemClock_Config(void);
    /* USER CODE BEGIN PFP */
    void vPGA460_WriteREG(uint8_t *data, uint16_t length)
    {
    	uint8_t buff[128] = {0};
    	buff[0] = 0x55;
    	memcpy(buff+1, data, length);
    	buff[length+1] = ucCalculateSumCheck(data, length);
    	HAL_UART_Transmit(&huart1, buff, length+2, 1000);
    }
    
    
    /* USER CODE END PFP */
    
    /* Private user code ---------------------------------------------------------*/
    /* USER CODE BEGIN 0 */
    uint8_t Stat0[10] = {0};
    uint8_t Stat1[10] = {0};
    uint8_t RECV_Measure[10] = {0};
    uint8_t RECV_BackMSG[130] = {0};
    
    #define 	READ_MeasureResult
    #ifdef		READ_MeasureResult
    		#define  	OUTMODE     0x20
    #else
    		#define  	OUTMODE     0x22
    #endif
    
    /* USER CODE END 0 */
    
    /**
      * @brief  The application entry point.
      * @retval int
      */
    int main(void)
    {
      /* USER CODE BEGIN 1 */
    
      /* USER CODE END 1 */
    
      /* MCU Configuration--------------------------------------------------------*/
    
      /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
      HAL_Init();
    
      /* USER CODE BEGIN Init */
    
      /* USER CODE END Init */
    
      /* Configure the system clock */
      SystemClock_Config();
    
      /* USER CODE BEGIN SysInit */
    
      /* USER CODE END SysInit */
    
      /* Initialize all configured peripherals */
      MX_GPIO_Init();
      MX_DMA_Init();
      MX_USART1_UART_Init();
      MX_USART2_UART_Init();
      /* USER CODE BEGIN 2 */
    
    //  initPGA460();
    
    //  uint8_t burnStat = burnEEPROM();
    
      uint8_t DEV_Stat1[] = {0x55, 0x09, 0x4C, ucCalculateSumCheck(DEV_Stat1+1, 2)};
      uint8_t DEV_Stat2[] = {0x55, 0x09, 0x4D, ucCalculateSumCheck(DEV_Stat2+1, 2)};
    
    
      uint8_t lock[] = {0x55, 0x0A, 0x40, 0x68, ucCalculateSumCheck(lock+1, 3)};
      uint8_t lock_on[] = {0x55, 0x0A, 0x40, 0x69, ucCalculateSumCheck(lock_on+1, 3)};
    
    #if 0
    
      uint8_t EE_W[46] = {0x55, 0X0C,
      	  	  	  	  	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    					  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      	  	  	  	  	  0X8D, 0XEE, 0XEF, 0X10, 0XA5, 0X20, 0XC1/*C1 *6*/, 0X40, 0X11/*11 200K FA 80*/, 0X80,
      	  	  	  	  	  0X10, 0X1F, 0X7F, 0X40/*40 2K*/, 0X11/*8.192 F9*/, 0X1B, 0X2C, 0X7C, 0X8F, 0X00, 0X00, 0X08, 0X18, ucCalculateSumCheck(EE_W+1, 44)};
    
      uint8_t EE_W_Default[46] = {0x55, 0X0C,
        	  	  	  	  	  	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    							  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    							  0XAF, 0XFF, 0XFF, 0X2D, 0X68, 0X36, 0XFC, 0XC0, 0X8C, 0X00,
    							  0X01, 0X12, 0X47, 0XFF, 0X1C, 0X00, 0XEE, 0X7C, 0X0A, 0X00, 0X00, 0X00, 0X00, ucCalculateSumCheck(EE_W_Default+1, 44)};
    
      vPGA460_SendMessage(EE_W, 46);
    //  vPGA460_SendMessage(EE_W_Default, 46);
      HAL_Delay(1);
    
      vPGA460_SendMessage(lock, 5);
      for(int i = 0; i<20; i++);
      vPGA460_SendMessage(lock_on, 5);
      HAL_Delay(1);
    
    
      uint8_t buff3[3] = {0x55};
      uint8_t buff99[50] = {0};
    	buff3[1] = 0x0B;
    	buff3[2] = calcChecksum(0x0B);
    	HAL_UART_Transmit(&huart1, buff3, 3, 1000);
    	for(int i = 0; i<10; i++);
    	HAL_UART_Receive(&huart1, buff99, 45, 0x1000);
    #endif
    
    	/**************************EE�����*****************************************/
    	  uint8_t DECPL_TEMP[] = {0x55, 0x0A, 0x26, 0x8F, ucCalculateSumCheck(DECPL_TEMP+1, 3)};
    	  vPGA460_SendMessage(DECPL_TEMP, 5);				//���ڻز�
    	  HAL_Delay(1);
    
    	  vPGA460_SendMessage(lock, 5);
    //	  for(int i = 0; i<20; i++);
    	  vPGA460_SendMessage(lock_on, 5);
    	  HAL_Delay(1);
    
    //	  uint8_t TVG25[] = {0x55, 0x0E, 0x88, 0x88, 0x88, 0x41, 0x04, 0x10, 0x40, ucCalculateSumCheck(TVG25+1, 8)};
    //	  vPGA460_SendMessage(TVG25, 10);
    //	  HAL_Delay(1);
    //
    //	  vPGA460_SendMessage(lock, 5);
    //	  for(int i = 0; i<20; i++);
    //	  vPGA460_SendMessage(lock_on, 5);
    //	  HAL_Delay(1);
    
    /*******************************************************************/
    
    
    /********************************�ز�����ת��******************************************/
    #ifdef  READ_MeasureResult
    	  uint8_t Back_off = 0x00;
    	  uint8_t EE_CNTRL[] = {0x55, 0x0A, 0x40, Back_off, ucCalculateSumCheck(EE_CNTRL+1, 3)};
    #else
    	  uint8_t Back_open = 0x80;
    	  uint8_t EE_CNTRL[] = {0x55, 0x0A, 0x40, Back_open, ucCalculateSumCheck(EE_CNTRL+1, 3)};
    #endif
    	  vPGA460_SendMessage(EE_CNTRL, 5);
    	  HAL_Delay(1);
    /************************************************************************************/
    
    /*********************************BPF��ͨ�˲���**********************************/
    	  uint8_t filter[] = {0xE1, 0x9F, 0xF9, 0xA5, 0x03, 0x2D};
    	  uint8_t filter_test[] = {0xDD, 0xBA, 0xF9, 0xA5, 0x03, 0x2D};
    	  uint8_t filter_write[] = {0x55, 0x0A, 0x41, filter[0], ucCalculateSumCheck(filter_write+1, 3)};
    	  for(int i = 0; i< 6; i++)
    	  {
    		  filter_write[3] = filter_test[i];
    		  filter_write[4] = ucCalculateSumCheck(filter_write+1, 3);
    		  vPGA460_SendMessage(filter_write, 5);
    		  filter_write[2]++;
    		  HAL_Delay(1);
    	  }
    	  uint8_t filter_read[4] = {0x55, 0x09, 0x41, ucCalculateSumCheck(filter_read+1, 2)};
    	  uint8_t filter_backRead[3] = {0};
    	  uint8_t filter_result[6] = {0};
    	  for(int n = 0; n< 6; n++)
    	  {
    
    		  filter_read[3] = ucCalculateSumCheck(filter_read+1, 2);
    		  vPGA460_SendMessage(filter_read, 4);
    		  for(int j = 0; j<20; j++);
    		  HAL_UART_Receive(&huart1, filter_backRead, 3, 0x500);
    		  filter_result[n] = filter_backRead[1];
    		  filter_read[2] ++;
    		  HAL_Delay(1);
    	  }
    
    /********************************************************************/
    
    /*********************************����ģ��ǰ�����*********************************************/
    	  uint8_t TEST_MUX[] = {0x55, 0x0A, 0x4B, OUTMODE, ucCalculateSumCheck(TEST_MUX+1, 3)};
    	  vPGA460_SendMessage(TEST_MUX, 5);
    	  HAL_Delay(1);
    /**************************************************************************/
    
    
    /******************************��ֵд��****************************************/
    	uint8_t THR[] = {0x55, 0x19, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x42, 0x10, 0x84, 0x21, 0x08, 0x40, 0x40, 0x40, 0x40, 0x00,
    								 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x42, 0x10, 0x84, 0x21, 0x08, 0x40, 0x40, 0x40, 0x40, 0x00, ucCalculateSumCheck(THR+1, 33)};
    
    	uint8_t THR1[] = {0x55, 0x19, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x84, 0x21, 0x08, 0x42, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00,
    								  0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x84, 0x21, 0x08, 0x42, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, ucCalculateSumCheck(THR1+1, 33)};
    	vPGA460_SendMessage(THR1, 35);
    	HAL_Delay(1);
    /*******************************************************************/
    
    	uint8_t burst[] = {0x55, 0x00, 0x01, ucCalculateSumCheck(burst+1, 2)};
    
    	uint8_t read_Measure[] = {0x55, 0x05, 0xFA};
    	uint8_t read_BackMSG[] = {0x55, 0x07, 0xFA};
    
      /* USER CODE END 2 */
    
      /* Infinite loop */
      /* USER CODE BEGIN WHILE */
      while (1)
      {
    #ifdef READ_MeasureResult
    
    	  memset(RECV_Measure, 0, sizeof(RECV_Measure)-1);
    	  HAL_UART_Transmit(&huart1, burst, 4, 1000);			//ͻ��Ƶ��
    	  HAL_Delay(10);
    	  vPGA460_SendMessage(read_Measure, 3);
    	  for(int i = 0; i<10; i++);
    	  HAL_UART_Receive(&huart1, RECV_Measure, 6, 0x500);
    
    #else
    	  memset(RECV_BackMSG, 0, sizeof(RECV_BackMSG));
    	  HAL_UART_Transmit(&huart1, burst, 4, 1000);			//ͻ��Ƶ��
    	  HAL_Delay(9);
    	  vPGA460_SendMessage(read_BackMSG, 3);
    	  for(int i = 0; i<10; i++);
    	  HAL_UART_Receive(&huart1, RECV_BackMSG, 130, 0x500);
    #endif
    	  if(RECV_Measure[1] != 0xFF && RECV_Measure[1] != 0 && RECV_Measure[1] != 0x88)
    	  {
    		  RECV_Measure[9]++;
    	  }
    
    	  HAL_Delay(1);
    	  HAL_UART_Transmit(&huart1, DEV_Stat1, 4, 1000);		//0x4C  EE CRC״̬
    	  for(int i = 0; i<10; i++);
    	  HAL_UART_Receive(&huart1, Stat0, 3, 1000);
    
    	  HAL_Delay(1);
    	  HAL_UART_Transmit(&huart1, DEV_Stat2, 4, 1000);		//0x4D  ���״̬
    	  for(int i = 0; i<10; i++);
    	  HAL_UART_Receive(&huart1, Stat1, 3, 1000);
    
    //	  vRS485_SendMessage(RECV_Measure, 6);
    //	  vSwitch_Output(Sig_Induction_HI, PNP, NO);
    	  HAL_Delay(1000);
        /* USER CODE END WHILE */
    
        /* USER CODE BEGIN 3 */
      }
      /* USER CODE END 3 */
    }
    
    /**
      * @brief System Clock Configuration
      * @retval None
      */
    void SystemClock_Config(void)
    {
      RCC_OscInitTypeDef RCC_OscInitStruct = {0};
      RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
    
      /** Configure the main internal regulator output voltage
      */
      HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
      /** Initializes the RCC Oscillators according to the specified parameters
      * in the RCC_OscInitTypeDef structure.
      */
      RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
      RCC_OscInitStruct.HSIState = RCC_HSI_ON;
      RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
      RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
      RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
      RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
      RCC_OscInitStruct.PLL.PLLN = 21;
      RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
      RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
      RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
      if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
      {
        Error_Handler();
      }
      /** Initializes the CPU, AHB and APB buses clocks
      */
      RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                                  |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
      RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
      RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
      RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
      RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    
      if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
      {
        Error_Handler();
      }
    }
    
    /* USER CODE BEGIN 4 */
    
    /* USER CODE END 4 */
    
    /**
      * @brief  This function is executed in case of error occurrence.
      * @retval None
      */
    void Error_Handler(void)
    {
      /* USER CODE BEGIN Error_Handler_Debug */
      /* User can add his own implementation to report the HAL error return state */
      __disable_irq();
      while (1)
      {
      }
      /* USER CODE END Error_Handler_Debug */
    }
    
    #ifdef  USE_FULL_ASSERT
    /**
      * @brief  Reports the name of the source file and the source line number
      *         where the assert_param error has occurred.
      * @param  file: pointer to the source file name
      * @param  line: assert_param error line source number
      * @retval None
      */
    void assert_failed(uint8_t *file, uint32_t line)
    {
      /* USER CODE BEGIN 6 */
      /* User can add his own implementation to report the file name and line number,
         ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
      /* USER CODE END 6 */
    }
    #endif /* USE_FULL_ASSERT */
    
    

  • Hello Jin,

    Thanks for the information, based on what you screenshotted here it is hard to help you debug. Do you mind taking a measurement and plotting the data using the echo data dump (128 byte down-sampled data collection) its hard to tell what the entire waveform looks like when there isnt a full visual of the data. I wouldn't try to dig into the different stages of the filter yet as this type of debugging is typically recommended when your data is filtered past the low pass filter stage which we havent seen. If you are having issues with the thresholding I think this may be an easier way to debug any issues with the thresholding you may be having looking at the data post the low pass filter. If we are not seeing a waveform for this stage then the issue could be upstream so I think it may be best to start at the end of the digital filtering chain first.

    Best.

    Isaac

  • As requested, I have plotted the echo data dump. For ease of analysis, I have combined the data for DP_MUX=1/2/3/4 into a single chart for comparison. Please refer to the attached file below:

    echo data dump.xlsx

  • Hello Jin,

    Thanks for the information and the data. It seems like you have a target that is clearly being detected and read by the sensor. I dont have the data here for the timing can you confirm what there is a target here and that the timing is correct? What is the distance of the target for these test measurements?

    If there is a target and the timing is correct then the filter settings seem to be correctly configured so we need to move away from using the test modes and run the same test using DP_MUX = 0x00 and command 7 from the UART to ensure that the data looks similar as when you are using DP_MUX = 0x01. 

    Best,

    Isaac

  • Do you mean that the above echo data dump is normal? Indeed, there is a target detected object in this chart, and the detected distance and time are accurate. By lowering the detection threshold, we can read the correct results. However, there is still a question with this chart; after the echo data passes through the filter, the amplitude is significantly reduced, leading me to believe that the filter parameters are incorrect. So, is it normal for the data amplitude to decrease so much when DP_MUX=0x01 compared to DP_MUX=0x04?

  • Hi Jin,

    Regarding the filter parameters, if the detected distance and time are accurate, then as Isaac previously mentioned, the setting should be correct. 

    So, is it normal for the data amplitude to decrease so much when DP_MUX=0x01 compared to DP_MUX=0x04?

    Yes, as different filters are being used, the data gets processed differently which is why you see the differences that you do.

    As a sanity check, using command 7 from the UART when DP_MUX = 0x00, are you able to read data similar to what you saw when DP_MUX = 0x01? 

    Best,

    ~Alicia

  • After reading the echo data dump, the data is similar  when DP_MUX=0 and DP_MUX=1, which, combined with the previous conclusions, suggests that the issue is almost resolved. Thank you very much for your reply.