<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10264/connecting-altimeter-to-nrf52-dk-using-i2c</link><description>Hi I trying to connect Altimeter ( mpl 3115a2) to the nrf52 development kit. Can someone guide me how to do it (pin connection). I have followed the example given in the sdk but still I am a little unclear.
Thank you.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 May 2016 09:38:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10264/connecting-altimeter-to-nrf52-dk-using-i2c" /><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38093?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 09:38:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80722a93-60d7-4d46-b54a-54a334a01ac1</guid><dc:creator>annapalu</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;i usea nrf52835, why you say that the pin of SDA are P0.26 and P 0.27?
Form product specification i read that the pin SWDCLCK and SWDIO are 26 and 25.
What is the different?&lt;/p&gt;
&lt;p&gt;Thanks,
Anna&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38099?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 07:54:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32e458a3-77d1-46bc-b2c4-e3bf817cf41b</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;Your read_reg() returns the unitialized &lt;code&gt;ret&lt;/code&gt;, not the actual register value.
Poll the STATUS register &lt;em&gt;until&lt;/em&gt; it is 1 and then do the reading. Currently you read the register once and it&amp;#39;s too early for the data to be ready.&lt;/p&gt;
&lt;p&gt;So you should have &lt;em&gt;something&lt;/em&gt; like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// reads a single 8-bit register and returns its value
static uint8_t read_reg( uint8_t slave_address, uint8_t register_address) {
    uint8_t buff;
    nrf_drv_twi_tx(&amp;amp;m_twi_master, slave_address, &amp;amp;register_address, 1, true);
    nrf_drv_twi_rx(&amp;amp;m_twi_master, slave_address, &amp;amp;buff, 1, false);
    return buff;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// initialization, activation

// read the status register until PTDR is set
while( !(read_reg(0x60, 0x00) &amp;amp; 0x08) );

// data should be ready when we get out of the while loop
// read_reg() and print
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38098?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 03:37:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56dd4779-b720-4e57-81bc-c732a97901a6</guid><dc:creator>Ank</dc:creator><description>&lt;p&gt;I wrote two functions to read and write register as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//Read and write register
static ret_code_t write_reg( uint8_t slave_address, uint8_t target_register, uint8_t data_to_write) {
	ret_code_t ret;
	nrf_drv_twi_tx(&amp;amp;m_twi_master, slave_address, &amp;amp;target_register, 1, true);
	size_t size = sizeof(data_to_write);
	nrf_drv_twi_tx(&amp;amp;m_twi_master, slave_address, &amp;amp;data_to_write, size, false);
	return ret;
}

static ret_code_t read_reg( uint8_t slave_address, uint8_t register_address) {
	
	ret_code_t ret;
	uint8_t buff[IN_LINE_PRINT_CNT];
	nrf_drv_twi_tx(&amp;amp;m_twi_master, slave_address, &amp;amp;register_address, 1, true);
	nrf_drv_twi_rx(&amp;amp;m_twi_master, slave_address, buff, IN_LINE_PRINT_CNT, false);
	return ret;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then according to the datasheet I did the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/*Set Altimeter with an OSR = 128 */
write_reg(0x60, 0x26, 0xB8);
/*Enable Data Flags in PT_DATA_CFG*/
write_reg(0X60, 0x13	, 0x07);
/*By Polling*/
/* Set Active*/
write_reg(0x60, 0x26, 0xB9);
/* Read Status register*/

int STA = read_reg(0x60, 0x00);

while ( (STA &amp;amp; 0x08) == 1) {
	int OUT_P_MSB = read_reg(0x60, 0x01);
	int OUT_P_CSB = read_reg(0x60, 0x02);
	int OUT_P_LSB = read_reg(0x60, 0x03);
	int OUT_T_MSB = read_reg(0x60, 0x04);
	int OUT_T_LSB = read_reg(0x60, 0x05);
	printf(&amp;quot; Raw data %d, %d, %d, %d, %d&amp;quot;, OUT_P_MSB, OUT_P_CSB, OUT_P_LSB, OUT_T_MSB, OUT_T_LSB);	
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But still I am not getting any output. But if I use it with the do_print_data and put the EEPROM_SIM_ADDR as 0x60 I get some random address but with 0xC0 I do not get any output. Any idea why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38100?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 06:55:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3c964ca-5b17-4613-b169-dbcc9070fd19</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;Yes with nrf_drv_twi_tx you write. First the register address, then the data. Like in the eeprom_write example function, something like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t target_register = 0x26;
nrf_drv_twi_tx(&amp;amp;m_twi_master, ALTIMETER_ADDRESS, &amp;amp;target_register, 1, true);
uint8_t data_to_write = 0xB8;
size_t size = sizeof(data_to_write);
nrf_drv_twi_tx(&amp;amp;m_twi_master, ALTIMETER_ADDRESS, &amp;amp;data_to_write, size, false);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38097?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 03:29:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:322e65c5-0496-4eaa-ba37-fb54e921f977</guid><dc:creator>Ank</dc:creator><description>&lt;p&gt;Thanks, this was really helpful. Just one more doubt, so i will have to use &lt;em&gt;nrf_drv_twi_tx&lt;/em&gt; to write to the register right ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38096?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2015 07:22:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17a322ef-2353-4636-9599-b4b5b5c06b81</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;In the twi_master_with_twis_slave example the pins and twi/s instances are defined in the file config.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define TWI_SCL_M                3   //!&amp;lt; Master SCL pin
#define TWI_SDA_M                4   //!&amp;lt; Master SDA pin

#define MASTER_TWI_INST          0    //!&amp;lt; TWI interface used as a master accessing EEPROM memory
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The macros are used in twi_master_init():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    const nrf_drv_twi_config_t config =
    {
       .scl                = TWI_SCL_M,
       .sda                = TWI_SDA_M,
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So in the example you can change TWI_SCL_M and TWI_SDA_M to be 27 and 26 respectively to match your circuit.&lt;/p&gt;
&lt;p&gt;The simulated EEPROM (slave) address is also defined in config.h:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define EEPROM_SIM_ADDR          0x50 //!&amp;lt; Simulated EEPROM TWI address
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the address is used like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    static ret_code_t eeprom_read(size_t addr, uint8_t * pdata, size_t size)
    {
...
           ret = nrf_drv_twi_tx(&amp;amp;m_twi_master, EEPROM_SIM_ADDR, &amp;amp;addr8, 1, true);
...
           ret = nrf_drv_twi_rx(&amp;amp;m_twi_master, EEPROM_SIM_ADDR, pdata, size, false);
...
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So EEPROM_SIM_ADDR above would in your altimeter&amp;#39;s case be changed to &lt;strong&gt;0xC0&lt;/strong&gt; (&lt;em&gt;datasheet p.6. ; 7bit address 0x60 &amp;lt;&amp;lt; 1&lt;/em&gt;). Otherwise the reads and writes are done similarly to how they&amp;#39;re done in the example.&lt;/p&gt;
&lt;p&gt;As for the read/write (register) addresses, you need to follow e.g. the sequence in MPL3115A2 datasheet p.10. IIC_RegWrite/Read are analogous to eeprom_write/read in the example (size=1).&lt;/p&gt;
&lt;p&gt;I hope I managed to answer your question and didn&amp;#39;t just blabber something... :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38092?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2015 03:28:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c948f749-4e4d-4088-a492-04f1a80de516</guid><dc:creator>Ank</dc:creator><description>&lt;p&gt;Hi, I am little new to all this, let me go step by step. According to the hardware files P 0.26 and P 0.27 are SDA and SCL respectively. So on the hardware side connection is like SDA -&amp;gt; SDA , SCL-&amp;gt; SCL, Vdd and gnd. This is pretty straight forward. I am confused on the hardware side. The example twi_master_with_twis_slave shows how the master reads the data from the eeprom. I am stuck where all changes I have to make to read the raw data from the sensor. Like where I have to define the pin no. for SDA and SCL and also for the slave address and read address. Can you help me on this issue.
Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38095?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2015 03:26:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15035e87-671d-4978-8292-cd45b8d1c311</guid><dc:creator>Ank</dc:creator><description>&lt;p&gt;Hi,
I am little new to all this, let me go step by step. According to the hardware files P 0.26 and P 0.27 are SDA and SCL respectively. So on the hardware side connection is like
SDA -&amp;gt; SDA , SCL-&amp;gt; SCL, Vdd and gnd.
This is pretty straight forward. I am confused on the hardware side. The example twi_master_with_twis_slave shows how the master reads the data from the eeprom. I am stuck where all changes I have to make to read the raw data from the sensor. Like where I have to define the pin no. for SDA and SCL and also for the slave address and read address. Can you help me on this issue.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38094?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2015 13:37:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e502c66-1257-4006-955a-14a978499ddf</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You can find reference circuitry for your sensor &lt;a href="https://cdn.sparkfun.com/datasheets/Sensors/Pressure/MPL3115A2_breakout.pdf"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The main thing to note is the external pull ups on SDA and SCL, otherwise you can connect SDA, SCL, and (optionally) INT1/INT2 directly to the nRF52 DK.&lt;/p&gt;
&lt;p&gt;Technically it is possible to use internal pull ups in the nRF52 to avoid the need for external pull ups, but having them externally gives you more control over the pull up resistance.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;
Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting Altimeter to nrf52 dk using i2c.</title><link>https://devzone.nordicsemi.com/thread/38091?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2015 11:01:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1fb27a7-c2e7-47cb-9f22-72560a920dea</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;Can you elaborate a bit? What exactly is unclear about connecting the sensor to the DK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>