<?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>I can not communicate with SPI and TWI with timer example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40738/i-can-not-communicate-with-spi-and-twi-with-timer-example</link><description>Hi, 
 I am using nRF_SDK_15.0.0_a53641 and writing a program with keil. 
 I am receiving data from the sensor with TWI communication and writing it to the sensor by SPI communication. 
 So I use timer example to periodically write data. 
 
 However, as</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Nov 2018 07:42:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40738/i-can-not-communicate-with-spi-and-twi-with-timer-example" /><item><title>RE: I can not communicate with SPI and TWI with timer example</title><link>https://devzone.nordicsemi.com/thread/158542?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 07:42:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f80cba9e-ee14-42f5-aa2e-e17e4cf3d123</guid><dc:creator>y001</dc:creator><description>&lt;p&gt;solved.&lt;br /&gt;Set a flag and set&lt;br /&gt;while (true)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; if (flag == true) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; // code&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; __ WFI ();&lt;br /&gt;}&lt;br /&gt;It solved it by doing.&lt;br /&gt;Thank you very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I can not communicate with SPI and TWI with timer example</title><link>https://devzone.nordicsemi.com/thread/158536?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 06:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe7a860c-c59c-4629-922d-3208105bda12</guid><dc:creator>y001</dc:creator><description>&lt;p&gt;Thank you for reply!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I wrote timer_event_handler like the code below, but no data was written to the SD card.&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#222222;float:none;font-family:arial,sans-serif;font-size:16px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;void timer_twi_event_handler(nrf_timer_event_t event_type, void* p_context)
{

    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE1:
					
        
		    TWI_start();//ST
	        nrf_delay_us(5);
		    twi_init();
	        nrf_delay_us(5);
	      	LM75B_set_mode();//SAD+W,SUB(SUB[7] set to 1)
         	nrf_delay_us(100);
        	TWI_start();//SR
	    	nrf_delay_us(600);//600-500
	    	read_sensor_data();//SAD+R
	    	nrf_delay_us(4);
	        TWI_stop();//SP
	    	nrf_delay_us(5);
	
	        //uint8 to short(16bit)
        	x = (short)(m_sample[1] &amp;lt;&amp;lt; 8 | m_sample[0]);
        	y = (short)(m_sample[3] &amp;lt;&amp;lt; 8 | m_sample[2]);
    		z = (short)(m_sample[5] &amp;lt;&amp;lt; 8 | m_sample[4]);


    
            x_g = (((float)x*2*2)/(float)65536);
	    	y_g = (((float)y*2*2)/(float)65536);
	    	z_g = (((float)z*2*2)/(float)65536);


	        sprintf(buf0,&amp;quot;%lf&amp;quot;,x_g);
	        sprintf(buf1,&amp;quot;%lf&amp;quot;,y_g);
	        sprintf(buf2,&amp;quot;%lf&amp;quot;,z_g);
				
            fatfs_example(buf0,buf1,buf2);
					
            break;

        default:
            //Do nothing.
            break;
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#222222;float:none;font-family:arial,sans-serif;font-size:16px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As a result of describing like this, it did not work well, so it did not work well using flags as follows.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void timer_twi_event_handler(nrf_timer_event_t event_type, void* p_context)
{

    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE1:
					
        
				flag = true;
					
            break;

        default:
            //Do nothing.
            break;
    }
}

int main(){
//config


    if (flag == 1){

    //my spi&amp;amp;twi code
    
    flag = false;

    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I was watching other questioner&amp;#39;s posts, I saw some people saying about priority, are there any relationships?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I can not communicate with SPI and TWI with timer example</title><link>https://devzone.nordicsemi.com/thread/158460?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 14:31:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17a03609-804f-4ace-86f8-66d8a9801915</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There should be no issues with using timer together with SPI and TWI. You need to describe the issue in more details, and include some code showing what you have tried and what is not working, in order to get any help.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>