<?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>compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64816/compiler-warning-pointer-from-integer-without-a-cast</link><description>Hello, 
 Would appreciate some understanding of a compiler warning. Developing for nRF52832 using SDK 15.3.0 plus S112. 
 This code compiles without warning: 
 
 Then I switch from nrfx to sd calls: 
 
 and the following warnings: 
 passing argument 2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 29 Aug 2020 03:26:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64816/compiler-warning-pointer-from-integer-without-a-cast" /><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/267057?ContentTypeID=1</link><pubDate>Sat, 29 Aug 2020 03:26:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:668826b9-bde2-4a95-bd3f-e7b44a1da5e2</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;Terje. Appreciate it.&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/266837?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 21:13:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:488c3986-e5e7-435d-b70a-5dea95d2a3dc</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From what I can tell, the two are equivalent (except for the second one missing the call to APP_ERROR_CHECK()). That is, both should compile to the same as long as the compiler does some minimal optimization.&lt;/p&gt;
&lt;p&gt;However I do find the first one easier to read and understand. It does fewer things per line, and also gives descriptive names to the arguments sent in to sd_ppi_channel_assign() by using temporary variables (event_addr and task_addr).&lt;/p&gt;
&lt;p&gt;When in doubt, use the one which is the easiest to understand for someone looking into this code in the future. That might be you, a couple of years from now.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/266831?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 19:27:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35b31026-cfe9-4de4-8b87-ca3bafcef100</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;J&amp;oslash;rgen. I think I understand.&lt;/p&gt;
&lt;p&gt;Am I correct to say that this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t err_code;
uint32_t event_addr = nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN);
uint32_t task_addr = nrfx_timer_task_address_get(&amp;amp;m_timer1,NRF_TIMER_TASK_START);
err_code = sd_ppi_channel_assign(chan_0, (const volatile void *)event_addr, (const volatile void *)task_addr);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;is equivalent to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t err_code;
err_code = sd_ppi_channel_assign(chan_0, (const volatile void *)nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN), (const volatile void *)nrfx_timer_task_address_get(&amp;amp;m_timer1,NRF_TIMER_TASK_START));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Any advantages of one compared to the other?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/266768?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 13:42:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:155f29c5-90d2-47bd-83e4-11e04504c59d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The correct approach is to cast the type&amp;nbsp;&lt;span&gt;(const volatile void *) when providing the variables (or events/task addresses). The&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v5.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;cp=4_7_3_5_2_7_2_26&amp;amp;anchor=gab1ca9bfe70cf943a6290516ddceb0a0f"&gt;sd_ppi_channel_assign&lt;/a&gt;() function is taking pointers, but the event/task addresses can be seen as pointers itself. It is therefore not correct to pass a pointer to the variables, as this will lead to PPI endpoints being set to addresses in RAM, which are not supported.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t err_code;
uint32_t event_addr = nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN);
uint32_t task_addr = nrfx_timer_task_address_get(&amp;amp;m_timer1,NRF_TIMER_TASK_START);
err_code = sd_ppi_channel_assign(chan_0, (const volatile void *)event_addr, (const volatile void *)task_addr);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/265817?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2020 14:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4f1d099-e979-4d89-ae7f-4cd4015f8261</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Also, when I search devzone, all posts with sd_ppi_channel_assign access peripherals (TIMER, GPIOTE, etc.) directly, except for &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/27973/ppi-with-softdevice" rel="noopener noreferrer" target="_blank"&gt;this post&lt;/a&gt;, which casts&amp;nbsp;nrf_drv_gpiote_in_event_addr_get and&amp;nbsp;nrf_drv_timer_task_address_get to&amp;nbsp;(const volatile void *). This&amp;nbsp;resolves the compiler warnings, but would like to confirm this is correct code.&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/265618?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 19:31:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27c6edb8-161f-4276-a400-a756f0edd828</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;Marjeris. Makes sense. I incorrectly assumed the function parameters were the same.&lt;/p&gt;
&lt;p&gt;However, it&amp;#39;s odd that it worked. Compiler warnings went away, but PPI stopped working when I changed the code to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t err_code;
uint32_t event_addr = nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN);
uint32_t task_addr = nrfx_timer_task_address_get(&amp;amp;m_timer1,NRF_TIMER_TASK_START);
err_code = sd_ppi_channel_assign(chan_0, &amp;amp;event_addr, &amp;amp;task_addr);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I need to debug and see if sd_ppi_channel_assign returns an error. Will do so, but thought to check if the above code looks correct to you.&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: compiler warning: pointer from integer without a cast</title><link>https://devzone.nordicsemi.com/thread/265316?ContentTypeID=1</link><pubDate>Wed, 19 Aug 2020 12:31:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:606979a9-96cf-40af-b149-1cb6ae502f2c</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Take a look at the API documentation for explanation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Fgroup__nrfx__ppi.html&amp;amp;cp=7_5_1_6_9_0_21_1_5&amp;amp;anchor=gae3d0c2c6e33fec27c262cd5ec87190db"&gt;nrfx_ppi_channel_assign&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v5.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;cp=4_7_3_5_2_7_2_26&amp;amp;anchor=gab1ca9bfe70cf943a6290516ddceb0a0f"&gt;sd_ppi_channel_assign&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The second one takes a pointer to a variable, while the first one takes a value. I would have call nrfx_gpiote_in_event_addr_get and nrfx_timer_task_address_get first and saved the results in their own variables that you can then pass via a pointer (&amp;amp;) to the sd_ppi_channel_assign.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s a bit surprising that you were able to compile with the wrong argument type. Pointers are the numbers containing the memory address of a variable instead of being the variable themselves. Therefore it could technically work, but would be very likely to behave incorrectly or even crash due to wrong values. That&amp;#39;s what the compiler is warning you about.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>