<?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>simple I2C question TC74</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47872/simple-i2c-question-tc74</link><description>I have a TC74 temp sensor 
 https://www.microchip.com/wwwproducts/en/TC74 
 and want the temperature 
 using code below I always get a greenlight / EVENTS ERROR 
 thank you in advance for any all help 
 
 int main(void) { short temperature = 0; 
 nrf_gpio_cfg_output</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 02 Jun 2019 19:43:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47872/simple-i2c-question-tc74" /><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190389?ContentTypeID=1</link><pubDate>Sun, 02 Jun 2019 19:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cce950ce-dd60-451f-a8e4-3721d11b3128</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;I fixed it. thank you&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;//need to declare in global fashion suggest putting in main.c file at top just after includes&lt;br /&gt;uint8_t temp_buffer[] = {0x01,0x00,0x00}; //used to READ temperature | STARTRX = 1 | stored in temp_buffer[0]&lt;/p&gt;
&lt;p&gt;/**&lt;br /&gt; * @brief Function for initializing the TC74&lt;br /&gt; */&lt;br /&gt;void InitializeTC74_TemperatureSensor(void)&lt;br /&gt;{&lt;br /&gt; nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs | P1.10 | MEMS_PWR_CTRL&lt;br /&gt; nrf_gpio_pin_clear(42); //PNP transistor so output low to power upp &amp;lt;see print 32341748&amp;gt;&lt;br /&gt; nrf_delay_ms(500); //give sensor time to power up&lt;/p&gt;
&lt;p&gt;uint8_t rx_buffer[]={0x00,0x00}; //used in STARTTX&lt;/p&gt;
&lt;p&gt;NRF_TWIM0-&amp;gt;ENABLE=0;//disable nordic as master to configure&lt;br /&gt; NRF_TWIM0-&amp;gt;PSEL.SCL=11;//P0.11&lt;br /&gt; NRF_TWIM0-&amp;gt;PSEL.SDA=13;//P0.13&lt;br /&gt; NRF_TWIM0-&amp;gt;FREQUENCY=0x01980000;//100kHz&lt;br /&gt; NRF_TWIM0-&amp;gt;ADDRESS=(0x48); // 1001 000--&amp;gt; x100 100 | x 1 fpr read 0 for write |NORDIC takes care of the read/write bit&lt;br /&gt; NRF_TWIM0-&amp;gt;RXD.PTR=temp_buffer;&lt;br /&gt; NRF_TWIM0-&amp;gt;RXD.MAXCNT=2; // size of temp_buffer&lt;br /&gt; NRF_TWIM0-&amp;gt;TXD.PTR=rx_buffer;&lt;br /&gt; NRF_TWIM0-&amp;gt;TXD.MAXCNT=1;//size of rx_buffer&lt;br /&gt; NRF_TWIM0-&amp;gt;SHORTS = 0;//disable shortcuts&lt;br /&gt; NRF_TWIM0-&amp;gt;ENABLE=6;//enable nordic as master&lt;/p&gt;
&lt;p&gt;//initialze TC74 to take data | normal mode&lt;br /&gt; NRF_TWIM0-&amp;gt;EVENTS_ERROR=0;&lt;br /&gt; NRF_TWIM0-&amp;gt;ERRORSRC=0; &lt;br /&gt; NRF_TWIM0-&amp;gt;EVENTS_STOPPED=0;&lt;br /&gt; NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;&lt;br /&gt; NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;&lt;br /&gt; while(NRF_TWI0-&amp;gt;EVENTS_TXDSENT==0){} &lt;br /&gt; NRF_TWIM0-&amp;gt;TASKS_STOP=1;&lt;br /&gt; NRF_TWI0-&amp;gt;EVENTS_TXDSENT=0;&lt;br /&gt; nrf_delay_ms(100);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;/**&lt;br /&gt; * @brief Function that returns temperature in degrees Celcius when called */&lt;br /&gt;uint8_t GetTemperature(void)&lt;br /&gt;{&lt;br /&gt; NRF_TWIM0-&amp;gt;TASKS_STARTTX = 0;&lt;br /&gt; NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;&lt;br /&gt; NRF_TWIM0-&amp;gt;TASKS_STARTRX = 1;&lt;br /&gt; while(NRF_TWI0-&amp;gt;EVENTS_RXDREADY==0){} &lt;br /&gt; NRF_TWIM0-&amp;gt;TASKS_STOP=1;&lt;br /&gt; NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;&lt;br /&gt; return temp_buffer[0];&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190108?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 20:41:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7b97efc-f9f7-46d8-b443-89e8c4c0ba4f</guid><dc:creator>awneil</dc:creator><description>[quote userid="80108" url="~/f/nordic-q-a/47872/simple-i2c-question-tc74/190106"]dont call me Shirley[/quote]
&lt;p&gt;Roger.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190106?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 20:36:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b7f46be-81f4-46dd-beb6-9134eceb246c</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;my mistake, the temperature register is 00&lt;/p&gt;
&lt;p&gt;and dont call me Shirley&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190100?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 17:54:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ecdd8fb-2d1b-44ef-b7b8-7905a62d1d7c</guid><dc:creator>awneil</dc:creator><description>[quote userid="80108" url="~/f/nordic-q-a/47872/simple-i2c-question-tc74/190099"]a configuration (read/write, register 01) and a temperature (read only, register 01)[/quote]
&lt;p&gt;Surely, they can&amp;#39;t &lt;em&gt;both&lt;/em&gt; be &lt;strong&gt;01&lt;/strong&gt; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190099?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 17:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa63a74c-5efe-4208-a56f-e9794b61dd0d</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;ok, still shooting in the dark here.&lt;/p&gt;
&lt;p&gt;I noticed that there are 2 registers, a configuration (read/write, register 01) and a temperature (read only, register 01).&lt;/p&gt;
&lt;p&gt;I added a write portion where the TXD pointer is pointing to a 2 component array (configuration register, value of zero).&amp;nbsp; the TC74 wants to see its address with the write bit, then the register writing to and then the value.&amp;nbsp; The nordic outputs the address, write bit, and then the pointer data so this seems compatible.&lt;/p&gt;
&lt;p&gt;TC74 wants to see address with read bit, register to read, repeat of address, then gives the data (figure 3-1 of datasheet &amp;lt;link in original post&amp;gt;). So i have the RX pointer to a 3 element array (configuration register, TC74 address, and zero that should hopefully get filled with the value of the configuration register - 6th bit should indicate data ready 4-8 times per second)&amp;nbsp; &amp;nbsp; &amp;nbsp; Figure 90 of the nrf52840 doesnt seem to agree with this scheme. and subsequently I never get notification that data is ready.&lt;/p&gt;
&lt;p&gt;any help or ideas to try would be greatly appreciated.&lt;pre class="ui-code" data-mode="c_cpp"&gt;   nrf_delay_ms(250);
    uint8_t transmit_buffer[2] = {0x01,0b00000000};//send 0 to configuration register 0x01 to enable normal mode (7th bit) and reset data ready (6th bit)
    uint8_t receive_buffer[3] = {0x01,0b1001000,0};//read from 0x01, repeat address (without read/write bit) due to change in dataflow direction, zero out data byte

    nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs
    nrf_gpio_pin_clear(42);
    nrf_delay_ms(500); //give sensor time to power up

    NRF_TWIM0-&amp;gt;ENABLE=0;//disable nordic as master to configure
    NRF_TWIM0-&amp;gt;PSEL.SCL=11;//P0.11
    NRF_TWIM0-&amp;gt;PSEL.SDA=13;//P0.13
    NRF_TWIM0-&amp;gt;FREQUENCY=0x01980000;//100kHz
    NRF_TWIM0-&amp;gt;ADDRESS=(0b1001000); // 1001 000--&amp;gt; x100 100 | x 1 fpr read 0 for write
    NRF_TWIM0-&amp;gt;RXD.PTR=receive_buffer;
    NRF_TWIM0-&amp;gt;RXD.MAXCNT=12;//only receive 1 byte but put at 12 just incase
    NRF_TWIM0-&amp;gt;TXD.PTR=transmit_buffer;
    NRF_TWIM0-&amp;gt;TXD.MAXCNT=8;
    NRF_TWIM0-&amp;gt;SHORTS = 0;
    NRF_TWIM0-&amp;gt;ENABLE=6;//enable nordic as master
    
    NRF_TWI0-&amp;gt;EVENTS_ERROR=0;
    NRF_TWIM0-&amp;gt;ERRORSRC=0;    
    NRF_TWI0-&amp;gt;EVENTS_STOPPED=0;
    nrf_delay_ms(250);
    NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;
    NRF_TWI0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWI0-&amp;gt;EVENTS_TXDSENT==0){}  
    NRF_TWI0-&amp;gt;TASKS_STOP=1;
    NRF_TWI0-&amp;gt;EVENTS_TXDSENT=0;
    nrf_delay_ms(500);
    

    NRF_TWI0-&amp;gt;EVENTS_ERROR=0;
    NRF_TWIM0-&amp;gt;ERRORSRC=0;    
    NRF_TWI0-&amp;gt;EVENTS_STOPPED=0;
    nrf_delay_ms(250);

  while(receive_buffer[2]==0) //waiting for data ready bit to be set (should happen 4 to 8 times a second)
  {
    NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;
    NRF_TWI0-&amp;gt;TASKS_STARTRX = 1;
    while(NRF_TWI0-&amp;gt;EVENTS_RXDREADY==0){}  
    NRF_TWI0-&amp;gt;TASKS_STOP=1;
    NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;
    nrf_delay_ms(50);
  }
    nrf_delay_ms(250);
    nrf_gpio_cfg_output(47); //GREEN
    nrf_gpio_pin_clear(47);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190068?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 13:24:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c86aa7d-c4ae-4d43-b05c-1421f06e846e</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;i shouldve been more specific, i meant an example of just how to get the read byte in my code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the manual says it is in pointer and to assign a location to pointer so i set NRF_TWIM0-&amp;gt;RXD.PTR = temperature which i made a short since it is only 1 byte of data but temperature is always zero and my sensor is at room temperature so it should be a nonzero number.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190064?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 12:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a9ab639-864a-4620-b862-aecdeaaf6ceb</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;yes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190062?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 12:54:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84c31c74-ee49-4a59-a1ae-baba4a259178</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Have you looked at the TWI examples in the SDK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/190061?ContentTypeID=1</link><pubDate>Thu, 30 May 2019 12:52:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e195707-7a92-449b-9542-df8214ffd47a</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;can you provide example of how to properly get /access the byte read?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/189983?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 21:01:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b5e639c-2d25-4489-b1d1-275860e091ca</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;i got the error to go away using&lt;/p&gt;
&lt;p&gt;NRF_TWI0-&amp;gt;TASKS_STARTRX = 1;&lt;br /&gt; while(NRF_TWI0-&amp;gt;EVENTS_RXDREADY==0){} &lt;br /&gt; NRF_TWI0-&amp;gt;TASKS_STOP=1;&lt;br /&gt; NRF_TWI0-&amp;gt;EVENTS_RXDREADY=0;&lt;br /&gt; temperature = NRF_TWI0-&amp;gt;RXD;&lt;/p&gt;
&lt;p&gt;but my temperature is zero. i must be receiving the temperature wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/189943?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 14:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b7ea8aa-9f85-40f6-8965-2a6659cf0cf8</guid><dc:creator>americanhoney</dc:creator><description>&lt;p&gt;From what I can see (red light &amp;#39;pin&amp;#39; 46) i am getting an overrun error.&amp;nbsp; I dont know how to fix or diagnose this though&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
int main(void)
{
    nrf_delay_ms(500);
    short temperature = 0;

    nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs
    nrf_gpio_cfg_output(46); //RED
    nrf_gpio_cfg_output(47); //GREEN
    nrf_gpio_pin_clear(42);
    nrf_gpio_pin_set(46);//turns off LED
    nrf_gpio_pin_set(47);//turns off LED

    NRF_TWIM0-&amp;gt;ENABLE=0;//disable nordic as master
    NRF_TWIM0-&amp;gt;PSEL.SCL=11;//P0.11
    NRF_TWIM0-&amp;gt;PSEL.SDA=13;//P0.13
    NRF_TWIM0-&amp;gt;FREQUENCY=0x01980000;//100kHz
    NRF_TWIM0-&amp;gt;ADDRESS=(0b11001000); // 1001 000--&amp;gt; x100 100 | x 1 fpr read 0 for write
    NRF_TWIM0-&amp;gt;RXD.PTR = temperature; //store 1 byte temperature in temperature variable
    NRF_TWIM0-&amp;gt;SHORTS = 0;
    NRF_TWI0-&amp;gt;INTENSET = 0x061C0202; // set interupts
    NRF_TWIM0-&amp;gt;ENABLE=6;//enable nordic as master
    NRF_TWI0-&amp;gt;EVENTS_ERROR=0;
    NRF_TWI0-&amp;gt;EVENTS_STOPPED=0;
    nrf_delay_ms(250);
    NRF_TWI0-&amp;gt;TASKS_STARTRX = 1;
    while (1)
    {
//    if(NRF_TWI0-&amp;gt;EVENTS_STOPPED) nrf_gpio_pin_clear(46);
  //  if(NRF_TWI0-&amp;gt;EVENTS_ERROR) nrf_gpio_pin_clear(47);//Always comes up with an error
    if(NRF_TWIM0-&amp;gt;ERRORSRC==1) nrf_gpio_pin_clear(46);//Always comes up with an error
    if(NRF_TWIM0-&amp;gt;ERRORSRC==2) nrf_gpio_pin_clear(47);
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/189932?ContentTypeID=1</link><pubDate>Wed, 29 May 2019 14:32:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f41af90-b1d2-4215-94e5-e2dd6bbfb515</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You may find the reason for the EVENTS_ERROR here:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/twim.html?cp=3_1_0_32_7_4#register.ERRORSRC"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/twim.html?cp=3_1_0_32_7_4#register.ERRORSRC&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: simple I2C question TC74</title><link>https://devzone.nordicsemi.com/thread/189723?ContentTypeID=1</link><pubDate>Tue, 28 May 2019 22:24:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a23cb4d5-94bd-4212-9766-0a25a91a69a1</guid><dc:creator>awneil</dc:creator><description>[quote userid="80108" url="~/f/nordic-q-a/47872/simple-i2c-question-tc74"]Always comes up with an error[/quote]
&lt;p&gt;&lt;em&gt;&lt;strong&gt;What&lt;/strong&gt; &lt;/em&gt;error?&lt;/p&gt;
&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1411._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>