Would evaluate some understanding of a compiler warning. Developing for nRF52832 utilizing SDK 15.3.0 to add S112.

You are watching: Makes pointer from integer without a cast

This password compiles without warning:

ret_code_t err_code;err_code = nrfx_ppi_channel_assign(chan_0, nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN),nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START));APP_ERROR_CHECK(err_code);

Then ns switch indigenous nrfx come sd calls:

ret_code_t err_code;err_code = sd_ppi_channel_assign(chan_0, nrfx_gpiote_in_event_addr_get(COMPARATOR_PIN),nrfx_timer_task_address_get(&m_timer1,NRF_TIMER_TASK_START));APP_ERROR_CHECK(err_code);

and the following warnings:

passing argument 2 of 'sd_ppi_channel_assign' makes guideline from integer there is no a cast <-Wint-conversion>

passing argument 3 that 'sd_ppi_channel_assign' makes reminder from integer there is no a cast <-Wint-conversion>

All seems to work, however would appreciate understanding the warnings.

Many thanks,

Tim


Top Replies



0
over 1 year ago
Marjeris Romero
4010pts.

Hi,

Take a look in ~ the API documentation because that explanation:

nrfx_ppi_channel_assign

sd_ppi_channel_assign

The second one take away a guideline to a variable, if the first one take away a value. I would certainly have call nrfx_gpiote_in_event_addr_get and also nrfx_timer_task_address_get first and saved the outcomes in their own variables that you have the right to then pass via a tip (&) to the sd_ppi_channel_assign.It's a little bit surprising the you were able to compile through the wrong argument type. Pointers space the numbers containing the memory attend to of a variable rather of gift the variable themselves. Therefore it can technically work, yet would be really likely come behave incorrectly or also crash because of wrong values. That's what the compiler is warning friend about.

Best regards,

Marjeris


*

0
end 1 year back
Tim
286pts.
in reply to Marjeris Romero

Thank youMarjeris. Makes sense. I mistakenly assumed the function parameters to be the same.

However, it's odd the it worked. Compiler warnings went away, but PPI stopped working once I readjusted the code to:

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(&m_timer1,NRF_TIMER_TASK_START);err_code = sd_ppi_channel_assign(chan_0, &event_addr, &task_addr);APP_ERROR_CHECK(err_code);

I have to debug and also see if sd_ppi_channel_assign return an error. Will do so, yet thought to check if the above code looks exactly to you.

Many thanks,

Tim


*

0
end 1 year earlier
Tim
286pts.
in answer to Tim

Also, once I find bromheads.tv, all articles with sd_ppi_channel_assign access peripherals (TIMER, GPIOTE, etc.) directly, other than for this post, i beg your pardon castsnrf_drv_gpiote_in_event_addr_get andnrf_drv_timer_task_address_get to(const volatile void *). Thisresolves the compiler warnings, yet would like to check this is correct code.

Many thanks,

Tim



0
over 1 year ago
Jørgen Holmefjord
28654pts.
in answer to Tim

Hi,

The correct strategy is to cast the type(const volatile void *) when providing the variables (or events/task addresses). Thesd_ppi_channel_assign() role is acquisition pointers, yet the event/task addresses have the right to be seen as pointers itself. The is thus not exactly to pass a reminder to the variables, together this will result in PPI endpoints being collection to addresses in RAM, which are not supported.

See more: Baby R Us Directions - Babies R Us In Asheville, Nc, Store Hours

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(&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);

Best regards,Jørgen


*

0
end 1 year earlier
Tim
286pts.
in answer to Jørgen Holmefjord

Thank youJørgen. Ns think ns understand.

Am i correct to say the this:

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(&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);

is equivalent to:

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(&m_timer1,NRF_TIMER_TASK_START));