Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

sd_ant_channel_assign fails when ucChannel is > 1

Rank

Total Posts: 4

Joined 2018-08-07

PM

Hi,

I am developing on nRF52832 using Nordic SDK v14.2.0 and softdevice S212. I started from the continuous scanning controller example found in Nordic's SDK, and now I would like to use ANT channels 1 to 15 as response channels. When I call sd_ant_channel_assign with ucChannel greater than 1, the call fails with error code 0x4033 (INVALID_PARAMETER_PROVIDED). I have set ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED to 15 in sdk_config.h.

Below is a minimal working example:

// initialize logging
    
ret_code_t err_code NRF_LOG_INIT(NULL);
    
APP_ERROR_CHECK(err_code);

    
NRF_LOG_DEFAULT_BACKENDS_INIT();
    
NRF_LOG_INFO("Hello world")

 
// sanity check, this prints 15
    
NRF_LOG_INFO("ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED = %d",
                 
ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED);

    
// initialize app timer
    
err_code app_timer_init();
    
APP_ERROR_CHECK(err_code);

    
// enable ANT softdevice
    
err_code nrf_sdh_enable_request();
    
APP_ERROR_CHECK(err_code);

    
ASSERT(nrf_sdh_is_enabled());

    
err_code nrf_sdh_ant_enable();
    
APP_ERROR_CHECK(err_code);

    
// configure ANT to report device ID and RSSI
    
err_code sd_ant_lib_config_set(
        
ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID |
        
ANT_LIB_CONFIG_MESG_OUT_INC_RSSI);
    
APP_ERROR_CHECK(err_code);

    
// channel config for continuous scanning slave
    
ant_channel_config_t channel_config {
        
.channel_number    ANT_SCAN_CHANNEL_NUMBER// = 0
        
.channel_type      CHANNEL_TYPE_SLAVE,
        .
ext_assign        0x00,
        .
rf_freq           RF_FREQ,
        .
transmission_type CHAN_ID_SLAVE_TRANS_TYPE// = 0
        
.device_type       CHAN_ID_SLAVE_DEV_TYPE// = 0
        
.device_number     0x00,
        .
channel_period    0x00,
        .
network_number    ANT_NETWORK_NUM// = 0
    
};

    
err_code ant_channel_init(&channel;_config);
    
APP_ERROR_CHECK(err_code);

    
// assign response channel 1
    
err_code sd_ant_channel_assign(1,
                                     
CHANNEL_TYPE_SLAVE,
                                     
ANT_NETWORK_NUM,
                                     
0x00);
    
APP_ERROR_CHECK(err_code); // <--- success

    // assign response channel 2
    
err_code sd_ant_channel_assign(2,
                                     
CHANNEL_TYPE_SLAVE,
                                     
ANT_NETWORK_NUM,
                                     
0x00);
    
APP_ERROR_CHECK(err_code); // <--- returns with 0x4033 


Any help is greatly appreciated.

Best,
Fredrik      
Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi Fredrik,

I am just re-posting this here for visibility but it looks like you still only have 2 channels allocated. This is the field which should be changed in sdk_config.h. The existing continuous scan example in the SDK allocates only 2 channels.

//  ANT Channels
 
//==========================================================
//  NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED - Allocated ANT channels.
#ifndef NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED
#define NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED 2
#endif 


Best regards,
Harrison      
Rank

Total Posts: 4

Joined 2018-08-07

PM

Hi Harrison, thanks for your reply.

It seems ANT_CONFIG_TOTAL_CHANNELS_ALLOCATED was renamed at some point in the SDK to NRF_SDH_ANT_TOTAL_CHANNELS_ALLOCATED, which is why my define had no effect. Thanks for clarifying, everything works fine now.