CHG + PPI CHG Register

Hey @avtolstoy

I’m working on some code with PPI (nrfx_ppi to be exact) and noticed that it’s trying to reference the pin definition for CHG instead of the register address of the same name.

Creating /Users/jaredwolff/Circuit_Dojo/dreamstar-cabinet/target/1.4.0/xenon/platform_user_ram.ld ...
In file included from ../hal/src/nRF52840/pinmap_impl.h:58:0,
                 from ../hal/inc/pinmap_hal.h:64,
                 from ../hal/inc/interrupts_hal.h:39,
                 from ../wiring/inc/spark_wiring.h:29,
                 from ./inc/application.h:40,
                 from /Users/jaredwolff/Circuit_Dojo/dreamstar-cabinet//src/dreamstar-cabinet.cpp:5:
../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal/nrf_ppi.h: In function 'void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t, nrf_ppi_channel_group_t)':
../hal/src/xenon/pinmap_defines.h:83:13: error: expected unqualified-id before numeric constant
 #define CHG 26
             ^
../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal/nrf_ppi.h:456:14: note: in expansion of macro 'CHG'
     NRF_PPI->CHG[(uint32_t) channel_group] =

I saw you were using PPI elsewhere in the code so I’m figuring you probably ran in to the same problem. Any suggestions? I’ve renamed CHG for now in my local testing but it’s going to be more tough once these devices get deployed. :slight_smile:

Right now I’m #undef CHG at the top of the file before including nrfx_ppi.h. Not sure if there’s a more elegant solution. :sweat_smile:

#undef would have been the solution I’d have suggested too - it’s probably the least simplest and least intrusive.

1 Like

Thanks @ScruffR!

@jaredwolff, @ScruffR, that’s what @rickkas7 did in his ADCDMAGen3_RK code which he got working in the Web IDE. Oddly, if I add nrfx_ppi.h I get odd errors. @jaredwolff, are you using the Web IDE or WorkBench for developing your code?

WorkBench only. I had originally re-named CHG to CHG_PIN and recompiled Device OS. That was until I found this workaround.

1 Like