This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting a DS2484 driver with I2C

I am trying to read a DS18B20 temperature sensor with I2C. I use a DS2484 driver to convert the I2C signals to a 1-Wire signal.

I have the following code:


/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx_hal.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c2;

RTC_HandleTypeDef hrtc;

/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C2_Init(void);
static void MX_RTC_Init(void);

/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
void ow_setup_ds2484(void);


/* USER CODE END PFP */

/* USER CODE BEGIN 0 */

        // I2C test
        //      uint8_t dummy_data[2] = {0};
        //      HAL_I2C_Master_Transmit (&hi2c2, 0x10, &dummy_data[0], 2, 1000); // 1sec timeout
                uint8_t byte_array[6];
                byte_array[0] = 0xE1; /* Data 0 */
    byte_array[1] = 0xC3; /* Data 1 */
                byte_array[2] = 0xD2; /* Data 2 */
                byte_array[3] = 0xEE; /* Data 3 */
  //  byte_array[4] = 0x00; /* Data 4 */

                        uint8_t dummy_data[25] =
                        {0xF0, // reset
                        0x01, //byte om data mee in te kunnen lezen
                        0xD2,//WCFG
                        0x22};

                        uint8_t dummy_data1[25] =
        {
                        0x22};


        HAL_I2C_Master_Transmit (&hi2c2, 0x30,  &dummy_data[0], 1, 1000); // reset device

                HAL_I2C_Master_Receive(&hi2c2, 0x31, &dummy_data[1] , 1, 1000); // lees byte in na reset


         HAL_I2C_Master_Transmit (&hi2c2, 0x30,  byte_array, 2, 1000); // set read pointer

        HAL_I2C_Master_Transmit (&hi2c2, 0x30,  &dummy_data[2], 1, 1000); // configureer

                HAL_I2C_Master_Receive(&hi2c2, 0x31, &dummy_data[1] , 1, 1000); // lees byte in na configureren


/* USER CODE END 0 */

int main(void)
{

/

  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I2C2_Init();
  MX_RTC_Init();

        ow_setup_ds2484();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */


  while (1)
  {
                        /* USER CODE END WHILE */
                        // --- toggle PC4 ---//
                        HAL_GPIO_WritePin (GPIOC,GPIO_PIN_9,GPIO_PIN_SET); // enable pin (vcc)
                        HAL_Delay (100);
                        HAL_GPIO_WritePin (GPIOC,GPIO_PIN_9,GPIO_PIN_RESET); // disable pin (0v)
                        HAL_Delay (100);




        } // while
} // main



void ow_setup_ds2484(void)
{

}



I followed the explanation of the datasheet:

Device Reset (After Power-Up)
S AD,0 A DRST A Sr AD,1 A <byte> A\ P
Activities that are underlined denote an optional read access to verify the success of the command.
Set Read Pointer (To Read from Another Register)
Case A: Valid Read Pointer Code
S AD,0 A SRP A C3h A P
C3h is the read pointer code for the Device Configuration register.
Case B: Invalid Read Pointer Code
S AD,0 A SRP A E5h A\ P
E5h is an invalid read pointer code.
Write Device Configuration (Before Starting 1-Wire Activity)
Case A: 1-Wire Idle (1WB = 0)
S AD,0 A WCFG A <byte> A Sr AD,1 A <byte> A\ P
Activities that are underlined denote an optional read access to verify the success of the command.
Case B: 1-Wire Busy (1WB = 1)
S AD,0 A WCFG A\ P
The master should stop and restart as soon as the DS2484 does not acknowledge the command code.
Adjust 1-Wire Port (after power-up, e.g., to select a 1-Wire timing other than the default)
Case A: 1-Wire Idle (1WB = 0)
Repeat to set additional port parameters
S AD,0 A ADJP A <byte> A <byte> A P

However, I still don't know what to do next to read the DS18B20 sensor. Plese help me :)