Interfacing DPS310 with CY8CPROTO-062-4343W

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User21513
Level 1
Level 1
First reply posted First question asked Welcome!

Hi! There is a sample code on the DPS Library of Modus ToolBox. I followed the steps given and modified the code to define the SDA and SCL pins of the Board.

However, it seems to not work.

 

 

#include "cyhal.h"
#include "cybsp.h"
#include "cy_retarget_io.h"
#include "xensiv_dps3xx_mtb.h"
xensiv_dps3xx_t pressure_sensor;
cyhal_i2c_t i2c;
cyhal_i2c_cfg_t i2c_cfg = {
.is_slave = false,
.address = 0,
.frequencyhal_hz = 400000
};
#define DPS_I2C_SDA (?) // Define me
#define DPS_I2C_SCL (?) // Define me
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init();
CY_ASSERT(result == CY_RSLT_SUCCESS);
__enable_irq();
/* Initialize retarget-io to use the debug UART port */
result = cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX, CY_RETARGET_IO_BAUDRATE);
CY_ASSERT(result == CY_RSLT_SUCCESS);
/* Initialize i2c for pressure sensor */
result = cyhal_i2c_init(&i2c, DPS_I2C_SDA, DPS_I2C_SCL, NULL);
CY_ASSERT(result == CY_RSLT_SUCCESS);
result = cyhal_i2c_configure(&i2c, &i2c_cfg);
CY_ASSERT(result == CY_RSLT_SUCCESS);
/* Initialize pressure sensor */
result = xensiv_dps3xx_mtb_init_i2c(&pressure_sensor, &i2c, MTB_DPS3XX_I2C_ADDR_DEFAULT);
CY_ASSERT(result == CY_RSLT_SUCCESS);
for (;;)
{
/* Get the pressure and temperature data and print the results to the UART */
float pressure, temperature;
xensiv_dps3xx_read(&pressure_sensor, &pressure, &temperature);
printf("Pressure : %8f\r\n", pressure);
printf("Temperature: %8f\r\n\r\n", temperature);
cyhal_system_delay_ms(1000);
}
}

 

 

 Is it possible to request for instructions with regards to the code and/or sample? Thank you

Regards, 

Aaron

0 Likes
1 Solution
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @User21513 ,

You have not defined the I2C pins here as well as the address of the DPS310 sensor.
Please make the following changes:

#define DPS_I2C_SDA    CYBSP_I2C_SDA   //Pin P6_1 for CY8CPROTO_062_4343W
#define DPS_I2C_SCL    CYBSP_I2C_SCL   //Pin P6_0 for CY8CPROTO_062_4343W
#define MTB_DPS3XX_I2C_ADDR_DEFAULT  0x77   //Address for DPS310


Please add the above defines in your code and connect the pins P6_0 of kit to SCL pin of DPS310 and pin P6_1 of kit to SDA pin of DPS310 sensor.

Warm Regards
Alen

View solution in original post

0 Likes
1 Reply
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @User21513 ,

You have not defined the I2C pins here as well as the address of the DPS310 sensor.
Please make the following changes:

#define DPS_I2C_SDA    CYBSP_I2C_SDA   //Pin P6_1 for CY8CPROTO_062_4343W
#define DPS_I2C_SCL    CYBSP_I2C_SCL   //Pin P6_0 for CY8CPROTO_062_4343W
#define MTB_DPS3XX_I2C_ADDR_DEFAULT  0x77   //Address for DPS310


Please add the above defines in your code and connect the pins P6_0 of kit to SCL pin of DPS310 and pin P6_1 of kit to SDA pin of DPS310 sensor.

Warm Regards
Alen

0 Likes