Hi,
After successfully compiling and flashing both the blinky example and the ble_app_hrs on my nRF52840 I ran into an issue with ANT Broadcast TX example. The example is written for the nRF52832 so I changed the make file and the rom and ram in the linker file to what I thought were the appropriate values for the 52840. It compiled just fine but when I try to flash the S212 soft device and the application hex it does not like it. I am not sure what going wrong during flashing. I have tried changing the main.c to simplify it down to the blinky example but I am still unable to flash. I have attached my simplified main.c, my makefile, and my linker file.
I have a few hunches as to what might be wrong. 1) the linker file has the incorrect origin/length flash/ram values. 2) the softdevice is not being initialized by the application correctly 3) some other file such as the sdk_config.h needs to be changed to work with the 52840.
I appreciate any help with this. Thank you!
/** * This software is subject to the ANT+ Shared Source License * www.thisisant.com/swlicenses * Copyright (c) Garmin Canada Inc. 2014 * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * 1) Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * 2) Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * 3) Neither the name of Garmin nor the names of its * contributors may be used to endorse or promote products * derived from this software without specific prior * written permission. * * The following actions are prohibited: * * 1) Redistribution of source code containing the ANT+ Network * Key. The ANT+ Network Key is available to ANT+ Adopters. * Please refer to http://thisisant.com to become an ANT+ * Adopter and access the key. * * 2) Reverse engineering, decompilation, and/or disassembly of * software provided in binary form under this license. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; DAMAGE TO ANY DEVICE, LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. SOME STATES DO NOT ALLOW * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE * ABOVE LIMITATIONS MAY NOT APPLY TO YOU. * */ /**@file * @defgroup nrf_ant_broadcast_tx_example ANT Broadcast TX Example * @{ * @ingroup nrf_ant_broadcast * * @brief Example of basic ANT Broadcast TX. * * Before compiling this example for NRF52, complete the following steps: * - Download the S212 SoftDevice from <a href="https://www.thisisant.com/developer/components/nrf52832" target="_blank">thisisant.com</a>. * - Extract the downloaded zip file and copy the S212 SoftDevice headers to <tt>\<InstallFolder\>/components/softdevice/s212/headers</tt>. * If you are using Keil packs, copy the files into a @c headers folder in your example folder. * - Make sure that @ref ANT_LICENSE_KEY in @c nrf_sdm.h is uncommented. */ #include <stdbool.h> #include <stdint.h> #include <string.h> #include "nrf.h" #include "bsp.h" #include "hardfault.h" #include "app_error.h" #include "app_timer.h" #include "nrf_sdh.h" #include "nrf_sdh_ant.h" #include "nrf_pwr_mgmt.h" #include "ant_interface.h" #include "ant_parameters.h" #include "ant_channel_config.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "nrf_delay.h" #include "nrf_gpio.h" #define APP_ANT_OBSERVER_PRIO 1 /**< Application's ANT observer priority. You shouldn't need to modify this value. */ /**@brief Function for setting payload for ANT message and sending it. */ void ant_message_send(void) { uint8_t message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE]; static uint8_t counter = 1u; memset(message_payload, 0, ANT_STANDARD_DATA_PAYLOAD_SIZE); // Assign a new value to the broadcast data. message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE - 1] = counter; // Broadcast the data. ret_code_t err_code = sd_ant_broadcast_message_tx(BROADCAST_CHANNEL_NUMBER, ANT_STANDARD_DATA_PAYLOAD_SIZE, message_payload); APP_ERROR_CHECK(err_code); counter++; } /**@brief Function for handling a ANT stack event. * * @param[in] p_ant_evt ANT stack event. * @param[in] p_context Context. */ static void ant_evt_handler(ant_evt_t * p_ant_evt, void * p_context) { ret_code_t err_code; nrf_pwr_mgmt_feed(); if (p_ant_evt->channel == BROADCAST_CHANNEL_NUMBER) { switch (p_ant_evt->event) { case EVENT_TX: ant_message_send(); err_code = bsp_indication_set(BSP_INDICATE_SENT_OK); APP_ERROR_CHECK(err_code); break; default: break; } } } NRF_SDH_ANT_OBSERVER(m_ant_observer, APP_ANT_OBSERVER_PRIO, ant_evt_handler, NULL); /**@brief Function for the Timer and BSP initialization. */ static void utils_setup(void) { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); err_code = bsp_init(BSP_INIT_LEDS, NULL); APP_ERROR_CHECK(err_code); err_code = nrf_pwr_mgmt_init(); APP_ERROR_CHECK(err_code); } /**@brief Function for ANT stack initialization. */ static void softdevice_setup(void) { ret_code_t 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); } /**@brief Function for setting up the ANT module to be ready for TX broadcast. */ static void ant_channel_tx_broadcast_setup(void) { ant_channel_config_t broadcast_channel_config = { .channel_number = BROADCAST_CHANNEL_NUMBER, .channel_type = CHANNEL_TYPE_MASTER, .ext_assign = 0x00, .rf_freq = RF_FREQ, .transmission_type = CHAN_ID_TRANS_TYPE, .device_type = CHAN_ID_DEV_TYPE, .device_number = CHAN_ID_DEV_NUM, .channel_period = CHAN_PERIOD, .network_number = ANT_NETWORK_NUM, }; ret_code_t err_code = ant_channel_init(&broadcast_channel_config); APP_ERROR_CHECK(err_code); // Fill tx buffer for the first frame. ant_message_send(); // Open channel. err_code = sd_ant_channel_open(BROADCAST_CHANNEL_NUMBER); APP_ERROR_CHECK(err_code); } /** *@brief Function for initializing logging. */ static void log_init(void) { ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } /**@brief Function for application main entry. Does not return. */ int main(void) { //log_init(); //utils_setup(); //softdevice_setup(); //ant_channel_tx_broadcast_setup(); nrf_gpio_cfg_output(36); NRF_LOG_INFO("ANT Broadcast TX example started."); // Main loop. for (;;) { //NRF_LOG_FLUSH(); //nrf_pwr_mgmt_run(); // Turn the LED on nrf_gpio_pin_set(36); nrf_delay_ms(1000); // Wait for 1 second // Turn the LED off nrf_gpio_pin_clear(36); nrf_delay_ms(1000); // Wait for 1 second } } /** *@} **/