This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 how to increase duty cycle to 98%

Hi Team,
Currently we are working with nrf52832 in one of our project and now we are going through FCC for the same. I am using radio tool code(SDK 15.3) to generate the FCC images for different channels. I am able to generate waveforms when i am using radio_modulated_tx_carrier() function. But in the testing we have observed that, with these we are able to achieve only 25% duty cycle. To increase the duty cycle, i have used radio_modulated_tx_carrier_duty_cycle() function, but after introducing this function i am not seeing wave forms in the spectrum. following is the code snippet

while (true){
uint8_t txpower_ = RADIO_TXPOWER_TXPOWER_Pos4dBm;
uint8_t mode_ = RADIO_MODE_MODE_Ble_1Mbit;
uint8_t channel_start_ = 40;
uint8_t duty_cycle = 98;

radio_modulated_tx_carrier_duty_cycle(txpower_,
mode_,
channel_start_,
duty_cycle);
}

Kindly let us know how to increase the duty cycle to 98%.

Parents
  • Hi,

     

    If you look inside the radio_modulated_tx_carrier_duty_cycle() you will see that the first thing it does is disable the radio (if it is running), so if you loop it you will just mess it up. Call it once, it uses a timer to loop itself, then call __WFE(), in the while loop:

    uint8_t txpower_ = RADIO_TXPOWER_TXPOWER_Pos4dBm;
    uint8_t mode_ = RADIO_MODE_MODE_Ble_1Mbit;
    uint8_t channel_start_ = 40;
    uint8_t duty_cycle = 98;
    
    radio_modulated_tx_carrier_duty_cycle(txpower_,
    mode_,
    channel_start_,
    duty_cycle);
    
    while (true){
        __WFE();
    }

     

    Best regards,

    Andreas

  • Hi Andreas,

    If we use the radio_modulated_tx_carrier_duty_cycle() function,we are unable to see the any signal in Spectrum analyzer but if we use the radio_modulated_tx_carrier() function we are able to see the BLE signal on Spectrum Analyzer,

    Please comment on  radio_modulated_tx_carrier_duty_cycle() function. what function we can use to increase Duty cycle.

    radio_modulated_tx_carrier_duty_cycle ( or) radio_modulated_tx_carrier

    Regards,

    Ramesh

  • Hi,

     

    Timer0_IRQ might not be enabled, try this for your main file:

    /**
     * Copyright (c) 2014-2018 - 2019, Nordic Semiconductor ASA
     *
     * 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, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, 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 Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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; 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.
     *
     */
    /** @file
     *
     * @defgroup nrf_radio_test_example_main main.c
     * @{
     * @ingroup nrf_radio_test_example
     * @brief Radio Test Example application main file.
     *
     * This file contains the source code for a sample application that uses the NRF_RADIO and is controlled through the serial port.
     *
     */
    
    
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "bsp.h"
    #include "nrf.h"
    #include "radio_test.h"
    #include "nordic_common.h"
    
    
    static uint8_t packet[256];
    static uint8_t mode_          = RADIO_MODE_MODE_Ble_1Mbit;
    static uint8_t txpower_       = RADIO_TXPOWER_TXPOWER_0dBm;
    static int channel_start_     = 40;
    
    
    
    /** @brief Function for configuring all peripherals used in this example.
     */
    static void init(void)
    {
        NRF_RNG->TASKS_START = 1;
    
    #ifndef NRF52810_XXAA
        NRF_NVMC->ICACHECNF  = NVMC_ICACHECNF_CACHEEN_Enabled << NVMC_ICACHECNF_CACHEEN_Pos;
    #endif // NRF52810_XXAA 
    
        // Start 64 MHz crystal oscillator.
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
      
       
        // Wait for the external oscillator to start up.
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /** @brief Function for the main application entry.
     */
    int main(void)
    {
     
        init();
        NVIC_ClearPendingIRQ(TIMER0_IRQn);
        NVIC_EnableIRQ(TIMER0_IRQn);
        radio_modulated_tx_carrier_duty_cycle(txpower_, mode_, channel_start_, 98);
     
        while (true)
        {
            __WFE();
        }
    }
    

     

    Best regards,

    Andreas

Reply
  • Hi,

     

    Timer0_IRQ might not be enabled, try this for your main file:

    /**
     * Copyright (c) 2014-2018 - 2019, Nordic Semiconductor ASA
     *
     * 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, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, 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 Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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; 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.
     *
     */
    /** @file
     *
     * @defgroup nrf_radio_test_example_main main.c
     * @{
     * @ingroup nrf_radio_test_example
     * @brief Radio Test Example application main file.
     *
     * This file contains the source code for a sample application that uses the NRF_RADIO and is controlled through the serial port.
     *
     */
    
    
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "bsp.h"
    #include "nrf.h"
    #include "radio_test.h"
    #include "nordic_common.h"
    
    
    static uint8_t packet[256];
    static uint8_t mode_          = RADIO_MODE_MODE_Ble_1Mbit;
    static uint8_t txpower_       = RADIO_TXPOWER_TXPOWER_0dBm;
    static int channel_start_     = 40;
    
    
    
    /** @brief Function for configuring all peripherals used in this example.
     */
    static void init(void)
    {
        NRF_RNG->TASKS_START = 1;
    
    #ifndef NRF52810_XXAA
        NRF_NVMC->ICACHECNF  = NVMC_ICACHECNF_CACHEEN_Enabled << NVMC_ICACHECNF_CACHEEN_Pos;
    #endif // NRF52810_XXAA 
    
        // Start 64 MHz crystal oscillator.
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
      
       
        // Wait for the external oscillator to start up.
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /** @brief Function for the main application entry.
     */
    int main(void)
    {
     
        init();
        NVIC_ClearPendingIRQ(TIMER0_IRQn);
        NVIC_EnableIRQ(TIMER0_IRQn);
        radio_modulated_tx_carrier_duty_cycle(txpower_, mode_, channel_start_, 98);
     
        while (true)
        {
            __WFE();
        }
    }
    

     

    Best regards,

    Andreas

Children
  • Thanks Andreas for your Reply...

    we are seeing only 50% duty cycle with below function in Spectrum Analyzer,But we are passing parameter duty_cycle as 98.

    radio_modulated_tx_carrier_duty_cycle(txpower_, mode_, channel_start_, 98);

    Please Let me know, how we can achieve to get exact 98% duty cycle.

    Regards,

    Ramesh

  • Hi Ramesh,

     

    Yes, you are right, sorry for not catching that. It seems to in some way or another be due to the radio not using fast ramp-up, enabling that seems to do the trick. I tested on my side with a proper spectrum analyzer this time, radio_modulated_tx_carrier_duty_cycle() for reference:

    void radio_modulated_tx_carrier_duty_cycle(uint8_t txpower,
                                               uint8_t mode,
                                               uint8_t channel,
                                               uint8_t duty_cycle)
    {
        // Lookup table with time per byte in each radio MODE
        // Mapped per NRF_RADIO->MODE available on nRF5-series devices @ref <insert ref to mode register>
        static const uint8_t time_in_us_per_byte[16] =
        {8, 4, 32, 8, 4, 64, 16, 0, 0, 0, 0, 0, 0, 0, 0, 32};
        // 1 byte preamble, 5 byte address (BALEN + PREFIX), and sizeof(payload), no CRC
        const uint32_t total_payload_size     = 1 + 5 + sizeof(m_tx_packet);
        const uint32_t total_time_per_payload = time_in_us_per_byte[mode] * total_payload_size;
        // Duty cycle = 100 * Time_on / (time_on + time_off), we need to calculate "time_off" for delay.
        // In addition, the timer includes the "total_time_per_payload", so we need to add this to the total timer cycle.
        uint32_t delay_time = total_time_per_payload +
                              ((100 * total_time_per_payload -
                              (total_time_per_payload * duty_cycle)) / duty_cycle);
    
        CRITICAL_REGION_ENTER();
        radio_disable();
        generate_modulated_rf_packet(mode);
        // We let the TIMER start the radio transmission again.
    
    
        NRF_RADIO->SHORTS    = RADIO_SHORTS_END_DISABLE_Msk | RADIO_SHORTS_READY_START_Msk;
        NRF_RADIO->TXPOWER   = (txpower << RADIO_TXPOWER_TXPOWER_Pos);
        NRF_RADIO->MODE      = (mode << RADIO_MODE_MODE_Pos);
        NRF_RADIO->FREQUENCY = channel;
    
        radio_channel_set(mode, channel);
    
        NRF_RADIO->MODECNF0 = 0x2001; // DTX = center, RU = fast
    
        NRF_TIMER0->TASKS_STOP  = 1;
        NRF_TIMER0->TASKS_CLEAR = 1;
        NRF_TIMER0->INTENSET    = (TIMER_INTENSET_COMPARE1_Set << TIMER_INTENSET_COMPARE1_Pos);
        NRF_TIMER0->SHORTS      =
            (TIMER_SHORTS_COMPARE1_CLEAR_Enabled << TIMER_SHORTS_COMPARE1_CLEAR_Pos);
        // Clear CC[0], in case sweep TX/RX was previously active
        NRF_TIMER0->CC[0]             = 0;
        NRF_TIMER0->CC[1]             = delay_time;
        NRF_TIMER0->EVENTS_COMPARE[0] = 0;
        NRF_TIMER0->EVENTS_COMPARE[1] = 0;
        NRF_TIMER0->BITMODE           = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
        NRF_TIMER0->PRESCALER         = 4; // resolution of 1 µs
        NRF_TIMER0->TASKS_START       = 1;
        
        CRITICAL_REGION_EXIT();
    }

     

    Note line 32.

     

    Best regards,

    Andreas

Related