<?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>How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54489/how-can-i-set-the-trigger-of-the-adxl362-to-a-specific-value</link><description>Hi, I am working with the adxl362 sensor on the Thingy91 and I want to set the trigger of the sensor to a specific value. 
 In the datasheet ( https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL362.pdf ), it says that the threshold</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Dec 2019 15:26:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54489/how-can-i-set-the-trigger-of-the-adxl362-to-a-specific-value" /><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/227090?ContentTypeID=1</link><pubDate>Mon, 30 Dec 2019 15:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93f0290b-455f-44dc-b30f-36acf24d118c</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;I solved it by my own with the help of the timing diagram:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1577719595423v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I have a working code for the read area of the diagram and I need a code that works for the write area of the diagram. I need to expand the buffer and send 3 bytes instead of 2. The working code is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void spi_write_reg(void)
{
  u8_t cmd =      0x0A;
  u8_t reg_addr = 0x20; // register, that you want to write
  u8_t value = 0x46; // value, that you want to set
  void *data = &amp;amp;value;
  int length = 1;
	u8_t access[3] = { cmd, reg_addr, value };

  gpio_pin_write(cs_gpio, cd_pin, 0);

	const struct spi_buf buf[2] = {
		{
			.buf = access,
			.len = 3
		},
		{
			.buf = data,
			.len = length
		}
	};
	struct spi_buf_set tx = {
		.buffers = buf,
	};


	const struct spi_buf_set rx = {
		.buffers = buf,
		.count = 2
	};

	tx.count = 1;

	int spi_result = spi_transceive(spi_dev, &amp;amp;spi_cfg, &amp;amp;tx, &amp;amp;rx);

 // printk(&amp;quot;SPI result: %d\n&amp;quot;,spi_result);
  printk(&amp;quot;Value: 0x%02X\n&amp;quot;, value);

  gpio_pin_write(cs_gpio, cd_pin, 1);

}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/224266?ContentTypeID=1</link><pubDate>Sat, 07 Dec 2019 07:23:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2397b6-0df4-4ef6-af84-6425c28470c1</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Hi, thanks for your code example. I am now able to read the registers too.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How did you managed to write the registers?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void spi_test_send(void)
{
	int err;
	static u8_t tx_buffer[1] = {0x0F};
	static u8_t rx_buffer[2]= {0x0A, 0x20};

        gpio_pin_write(cs_gpio, cd_pin, 0);


	const struct spi_buf tx_buf = {
		.buf = tx_buffer,
		.len = sizeof(tx_buffer)
	};
	const struct spi_buf_set tx = {
		.buffers = &amp;amp;tx_buf,
		.count = 1
	};

	struct spi_buf rx_buf = {
		.buf = rx_buffer,
		.len = sizeof(rx_buffer),
	};
	const struct spi_buf_set rx = {
		.buffers = &amp;amp;rx_buf,
		.count = 1
	};

	err = spi_transceive(spi_dev, &amp;amp;spi_cfg, &amp;amp;tx, &amp;amp;rx);
	if (err) {
		printk(&amp;quot;SPI error: %d\n&amp;quot;, err);
	} else {
		/* Connect MISO to MOSI for loopback */
		printk(&amp;quot;TX sent: %x\n&amp;quot;, tx_buffer[0]);
		printk(&amp;quot;RX recv: %x\n&amp;quot;, rx_buffer[0]);
	}
        gpio_pin_write(cs_gpio, cd_pin, 1);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I wanted to try to write the 0x20 (Lower Threshold) with the value 0x0F with the code above.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1575703132343v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Do I have to add the 0x0A? Or how do I have to write these two lines correctly then?:&lt;/p&gt;
&lt;p&gt;static u8_t tx_buffer[1] = {0x0F};&lt;br /&gt; static u8_t rx_buffer[2]= {0x0A, 0x20};&lt;/p&gt;
&lt;p&gt;Do I need here the&amp;nbsp;&lt;/p&gt;
&lt;p&gt;gpio_pin_write(cs_gpio, cd_pin, 0);&lt;br /&gt;gpio_pin_write(cs_gpio, cd_pin, 1);&lt;/p&gt;
&lt;p&gt;like in the read function?&lt;/p&gt;
&lt;p&gt;Thanks for your help and your answers!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/222968?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 09:07:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2c3156c-a5fc-4efc-9062-b492d3e6b665</guid><dc:creator>MJD093</dc:creator><description>&lt;p&gt;Hi there,&lt;br /&gt;&lt;br /&gt;I had a similar issue in the past with the ADXL362. Have a look at this thread and try running the example code I listed there. You should be able to read the ADXL362&amp;#39;s part ID. From that you should be able to start reading through the Datasheet and building you application. &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/52279/how-to-get-accelerometer-value-of-thingy-91"&gt;devzone.nordicsemi.com/.../how-to-get-accelerometer-value-of-thingy-91&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/222915?ContentTypeID=1</link><pubDate>Sun, 01 Dec 2019 16:36:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79da429b-2f29-406a-8134-605739cbba8a</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Hi, sorry for the delay.&lt;/p&gt;
&lt;p&gt;That doesn&amp;#39;t really work, my skills are not good enough.&lt;/p&gt;
&lt;p&gt;Do you maybe have a example code, where you write the register of the adxl362 or another sensor?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to import the driver files in&amp;nbsp;&lt;span&gt;zephyr\drivers\sensor\adxl362\, but when I wanted to write a register, I got an spi error. So could you maybe provide an example program?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your help!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/221692?ContentTypeID=1</link><pubDate>Sat, 23 Nov 2019 11:20:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b352a3bc-cbc7-468b-9ab8-350dfa8b2d19</guid><dc:creator>Tejaswini</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am also facing same issue. Means after setting SENSOR_ATTR_LOWER_THRESH and SENSOR_ATTR_UPPER_THRESH in driver code, how we can compare them in application code.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Can you please share in detail , how you solved it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I set the trigger of the adxl362 to a specific value?</title><link>https://devzone.nordicsemi.com/thread/220551?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 12:06:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:129e4ece-cac3-46aa-b61d-432c98cc9b6b</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Does someone could give me an example code line on how to set the trigger?[/quote]
&lt;p&gt;Have a look at our&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/sensor/bh1749/README.html#bh1749-ambient-light-sensor-ic"&gt;BH1749 sample&lt;/a&gt;&amp;nbsp;(nrf\samples\sensor\bh1749&lt;strong&gt;)&lt;/strong&gt;, and the ADXL362 drivers found here:&amp;nbsp;zephyr\drivers\sensor\adxl362\&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>