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.

TMP126: Reading register values 1st read occurring correctly after that garbage values are occurring.

Part Number: TMP126

I am using stm32f2 series as master to access data from TMP126.

SPI configuration:

Full duplex master mode

mode: CPOL=0 CPAHASE=0 (mode 0)

data size=8bit

First bit= MSB

when i read single register first time after dumping or restarting it will give exact default values.

when i read in the while loop continuously it will read first iteration default values  afterwards it will give the garbage values.

1) i tried with Repeated Data Read from a Single Register frame format =0x03 0x0C 

 1st iteration reading 0x2126  after that garbage values


2)  i tried with  Burst Data Read from Multiple Registers =0x03 0x00 to till 07h register

1st read 0 to 07 h reads correctly 

after that garbage values are occurring.

https://postimg.cc/gallery/tj1Nywj

but in both case 1 iteration it will read the default values afterwards unknown values will be read.

My code snippet

void tmp_get8bit(uint8_t *txbuff,uint8_t *rxbuff,int size)

{

uint8_t chrxbuff[size];

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);

HAL_Delay(5); //milisec

HAL_SPI_TransmitReceive(&hspi3, txbuff, chrxbuff, size, 500);

HAL_Delay(5);//milisec

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);

rxbuff[0]=chrxbuff[2];

rxbuff[1]=chrxbuff[3];

}

int main(void)

{

HAL_Init();

SystemClock_Config();

MX_GPIO_Init();

MX_SPI3_Init();

uint8_t txbuff[18]={0x03,0x0C};

while (1)

{

uint8_t rxbuff[2];

MX_SPI3_Init();

tmp_get8bit(txbuff,rxbuff,6);

}

}

static void MX_SPI3_Init(void)

{

/* USER CODE BEGIN SPI3_Init 0 */

/* USER CODE END SPI3_Init 0 */

/* USER CODE BEGIN SPI3_Init 1 */

/* USER CODE END SPI3_Init 1 */

/* SPI3 parameter configuration*/

hspi3.Instance = SPI3;

hspi3.Init.Mode = SPI_MODE_MASTER;

hspi3.Init.Direction = SPI_DIRECTION_2LINES;

hspi3.Init.DataSize = SPI_DATASIZE_8BIT;

hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;

hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;

hspi3.Init.NSS = SPI_NSS_SOFT;

hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;

hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi3.Init.TIMode = SPI_TIMODE_DISABLE;

hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi3.Init.CRCPolynomial = 10;

if (HAL_SPI_Init(&hspi3) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN SPI3_Init 2 */

/* USER CODE END SPI3_Init 2 */

}

Regards,

Sandeep C

  • Hi Sandeep,

    Can you please show your schematic? It's critical that the data in/out signal is connected as a bidirectional signal for this device. Your logic analyzer could be hiding logic level issues.

    I also noticed that you are always using Auto Increment, even when you state that you are doing a single read. 

    You will have to pull the CS pin high after each transaction, and I can't see that happening in your logic analyzer. This could be why the data is not as expected.

    thanks,

    ren

  • Note: There are 4 TMP126 are connected to the Master

    SPI config:

    Full duplex master mode

    mode: CPOL=0 CPAHASE=0 (mode 0)

    data size=8bit

    First bit= MSB

    clock =5mhz 

    yes i tried with that also, here is the code.

    1) if read same registers continuously getting results. even if read the temperature it will vary i tried with giving external heat to the IC.

    if read chip id continuously i am getting the exact chip id even if read multiple times

    problem

    1) once i read the chip id first after am trying to read the temperature at 0x00 register. still it returns the chip id it self.

    2) once i read the temperature first it gives the temperature values correctly if temp varied also i am getting results. after this if i read chip id i wont get chip id.

    as you mentioned i tried forcefully delay after making pin low to stabilize low pin and even when pin making high.

    2) if read temperature first it gives the results afterwards if read chip id wont get proper chip.

    code 1:

    /* USER CODE BEGIN Header */
    /**
     ******************************************************************************
     * @file           : main.c
     * @brief          : Main program body
     ******************************************************************************
     * @attention
     *
     * Copyright (c) 2024 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"
    
    /* 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 ---------------------------------------------------------*/
    SPI_HandleTypeDef hspi3;
    
    /* USER CODE BEGIN PV */
    
    /* USER CODE END PV */
    
    /* Private function prototypes -----------------------------------------------*/
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_SPI3_Init(void);
    /* USER CODE BEGIN PFP */
    
    /* USER CODE END PFP */
    
    /* Private user code ---------------------------------------------------------*/
    /* USER CODE BEGIN 0 */
    volatile static uint16_t devid;
    float tmp126;
    
    
    void temp_read(void)
    {
    	uint8_t txbuff[4]={0x01,0x00};
    	uint8_t chrxbuff[4];
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    	HAL_Delay(5);
    	HAL_SPI_Transmit(&hspi3, txbuff, 4, 1000);
    	HAL_SPI_Receive(&hspi3, chrxbuff, 4, 1000);
    	HAL_Delay(5);
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
    	HAL_Delay(100);
    
    	tmp126=(((int16_t) chrxbuff[2] << 8 | chrxbuff[3]) >> 2) * 0.03125;
    
    }
    
    void temp_devid(uint16_t *devid)
    {
    
    	uint8_t txbuff1[4]={0x01,0x0C};
    	uint8_t rxbuff[4];
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    	HAL_Delay(5);
    
    	HAL_SPI_Transmit(&hspi3, txbuff1, 4, 1000);
    	HAL_SPI_Receive(&hspi3, rxbuff, 4, 1000);
    	HAL_Delay(5);
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
    	HAL_Delay(100);
    
    	*devid=(rxbuff[2] << 8) | rxbuff[3];
    }
    
    static int a=0;
    
    /* 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_SPI3_Init();
    	/* USER CODE BEGIN 2 */
    
    	/* USER CODE END 2 */
    
    	/* Infinite loop */
    	/* USER CODE BEGIN WHILE */
    	while (1)
    	{
    		uint16_t devid;
    
    		temp_devid(&devid);
    //		temp_read();
    		a=1;
    
    		/* 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};
    
    	/** 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 = 10;
    	RCC_OscInitStruct.PLL.PLLN = 200;
    	RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
    	RCC_OscInitStruct.PLL.PLLQ = 4;
    	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_DIV16;
    	RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
    
    	if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
    	{
    		Error_Handler();
    	}
    }
    
    /**
     * @brief SPI3 Initialization Function
     * @param None
     * @retval None
     */
    static void MX_SPI3_Init(void)
    {
    
    	/* USER CODE BEGIN SPI3_Init 0 */
    
    	/* USER CODE END SPI3_Init 0 */
    
    	/* USER CODE BEGIN SPI3_Init 1 */
    
    	/* USER CODE END SPI3_Init 1 */
    	/* SPI3 parameter configuration*/
    	hspi3.Instance = SPI3;
    	hspi3.Init.Mode = SPI_MODE_MASTER;
    	hspi3.Init.Direction = SPI_DIRECTION_2LINES;
    	hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
    	hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
    	hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
    	hspi3.Init.NSS = SPI_NSS_SOFT;
    	hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
    	hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
    	hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
    	hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    	hspi3.Init.CRCPolynomial = 10;
    	if (HAL_SPI_Init(&hspi3) != HAL_OK)
    	{
    		Error_Handler();
    	}
    	/* USER CODE BEGIN SPI3_Init 2 */
    
    	/* USER CODE END SPI3_Init 2 */
    
    }
    
    /**
     * @brief GPIO Initialization Function
     * @param None
     * @retval None
     */
    static void MX_GPIO_Init(void)
    {
    	GPIO_InitTypeDef GPIO_InitStruct = {0};
    	/* USER CODE BEGIN MX_GPIO_Init_1 */
    	/* USER CODE END MX_GPIO_Init_1 */
    
    	/* GPIO Ports Clock Enable */
    	__HAL_RCC_GPIOE_CLK_ENABLE();
    	__HAL_RCC_GPIOB_CLK_ENABLE();
    	__HAL_RCC_GPIOA_CLK_ENABLE();
    	__HAL_RCC_GPIOC_CLK_ENABLE();
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    
    	/*Configure GPIO pins : PE14 PE15 */
    	GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    
    	/*Configure GPIO pin : PB10 */
    	GPIO_InitStruct.Pin = GPIO_PIN_10;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    
    	/*Configure GPIO pin : PA15 */
    	GPIO_InitStruct.Pin = GPIO_PIN_15;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    
    	/* USER CODE BEGIN MX_GPIO_Init_2 */
    	/* USER CODE END MX_GPIO_Init_2 */
    }
    
    /* 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 */

    Code 2: forcefully all slave CS pins making high i wont get as i requested chip id or temperature even  at the first time.

    /* USER CODE BEGIN Header */
    /**
     ******************************************************************************
     * @file           : main.c
     * @brief          : Main program body
     ******************************************************************************
     * @attention
     *
     * Copyright (c) 2024 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"
    
    /* 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 ---------------------------------------------------------*/
    SPI_HandleTypeDef hspi3;
    
    /* USER CODE BEGIN PV */
    
    /* USER CODE END PV */
    
    /* Private function prototypes -----------------------------------------------*/
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_SPI3_Init(void);
    /* USER CODE BEGIN PFP */
    
    /* USER CODE END PFP */
    
    /* Private user code ---------------------------------------------------------*/
    /* USER CODE BEGIN 0 */
    volatile static uint16_t devid;
    float tmp126;
    
    
    void temp_read(void)
    {
    	uint8_t txbuff[4]={0x01,0x00};
    	uint8_t chrxbuff[4];
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    	HAL_Delay(5);
    	HAL_SPI_Transmit(&hspi3, txbuff, 4, 1000);
    	HAL_SPI_Receive(&hspi3, chrxbuff, 4, 1000);
    	HAL_Delay(5);
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
    	HAL_Delay(100);
    
    	tmp126=(((int16_t) chrxbuff[2] << 8 | chrxbuff[3]) >> 2) * 0.03125;
    
    }
    
    void temp_devid(uint16_t *devid)
    {
    
    	uint8_t txbuff1[4]={0x01,0x0C};
    	uint8_t rxbuff[4];
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    	HAL_Delay(5);
    
    	HAL_SPI_Transmit(&hspi3, txbuff1, 4, 1000);
    	HAL_SPI_Receive(&hspi3, rxbuff, 4, 1000);
    	HAL_Delay(5);
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
    	HAL_Delay(100);
    
    	*devid=(rxbuff[2] << 8) | rxbuff[3];
    }
    
    static int a=0;
    
    /* 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_SPI3_Init();
    	/* USER CODE BEGIN 2 */
    
    	/* USER CODE END 2 */
    
    	/* Infinite loop */
    	/* USER CODE BEGIN WHILE */
    	while (1)
    	{
    		uint16_t devid;
    		HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_SET);
    
    		/*Configure GPIO pin Output Level */
    		HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET);
    
    		/*Configure GPIO pin Output Level */
    		HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
    
    		temp_devid(&devid);
    //		temp_read();
    		a=1;
    
    		/* 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};
    
    	/** 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 = 10;
    	RCC_OscInitStruct.PLL.PLLN = 200;
    	RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
    	RCC_OscInitStruct.PLL.PLLQ = 4;
    	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_DIV16;
    	RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
    
    	if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
    	{
    		Error_Handler();
    	}
    }
    
    /**
     * @brief SPI3 Initialization Function
     * @param None
     * @retval None
     */
    static void MX_SPI3_Init(void)
    {
    
    	/* USER CODE BEGIN SPI3_Init 0 */
    
    	/* USER CODE END SPI3_Init 0 */
    
    	/* USER CODE BEGIN SPI3_Init 1 */
    
    	/* USER CODE END SPI3_Init 1 */
    	/* SPI3 parameter configuration*/
    	hspi3.Instance = SPI3;
    	hspi3.Init.Mode = SPI_MODE_MASTER;
    	hspi3.Init.Direction = SPI_DIRECTION_2LINES;
    	hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
    	hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
    	hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
    	hspi3.Init.NSS = SPI_NSS_SOFT;
    	hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
    	hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
    	hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
    	hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    	hspi3.Init.CRCPolynomial = 10;
    	if (HAL_SPI_Init(&hspi3) != HAL_OK)
    	{
    		Error_Handler();
    	}
    	/* USER CODE BEGIN SPI3_Init 2 */
    
    	/* USER CODE END SPI3_Init 2 */
    
    }
    
    /**
     * @brief GPIO Initialization Function
     * @param None
     * @retval None
     */
    static void MX_GPIO_Init(void)
    {
    	GPIO_InitTypeDef GPIO_InitStruct = {0};
    	/* USER CODE BEGIN MX_GPIO_Init_1 */
    	/* USER CODE END MX_GPIO_Init_1 */
    
    	/* GPIO Ports Clock Enable */
    	__HAL_RCC_GPIOE_CLK_ENABLE();
    	__HAL_RCC_GPIOB_CLK_ENABLE();
    	__HAL_RCC_GPIOA_CLK_ENABLE();
    	__HAL_RCC_GPIOC_CLK_ENABLE();
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);
    
    	/*Configure GPIO pin Output Level */
    	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
    
    	/*Configure GPIO pins : PE14 PE15 */
    	GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    
    	/*Configure GPIO pin : PB10 */
    	GPIO_InitStruct.Pin = GPIO_PIN_10;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    
    	/*Configure GPIO pin : PA15 */
    	GPIO_InitStruct.Pin = GPIO_PIN_15;
    	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    	GPIO_InitStruct.Pull = GPIO_PULLUP;
    	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    	HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    
    	/* USER CODE BEGIN MX_GPIO_Init_2 */
    	/* USER CODE END MX_GPIO_Init_2 */
    }
    
    /* 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 */
    

    we changed 10k to the MISO side as given in the datasheet.

    can i get clarification about my spi configuration?

    For does it make sense of TI mode SPI or Motorola mode SPI.?

    Regards

    Sandeep C

  • HI Sandeep,

    I am replying on Ren's behalf today to let you know he is out of office and will respond to your reply on Monday. 

    Thank you for your patience.

    Regards

    -Alex Thompson

  • The timing diagrams for TMP126 show that it samples on rising edge. It should be compatible with CPOL0/CPHA0 and CPOL1/CPHA1. 

    You shouldn't need to add explicit CS delays for tLEAD and tLAG as these specs are 100 and 20 ns, respectively, and delays are typically measured in ms.

    I don't believe you are getting incorrect data. I think you are simply misunderstanding operation of the device. I will need to see more logic analyzer waveforms of the problem you are facing to comment further. For your complaints about a transaction corrupting the transaction that follows, I will need to see the waveform for both and preferably everything that happened between.

    thanks,

    ren

  • Thanks for the response,

    just for verification i had given those delay.

    our slaves far from from controller about 40cm, so we have to probe the clock clk, mosi and mosi lines, whether data reaching to the devices are not.

    I will update you as soon as possible.