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

How to configure nrf52832 without the 32kHZ crystal.

Hello there, I am working on a customized nrf52832 board. For the limited size, the 32kHz crystal is not install because I think the clock from 32khz crystal can be replaced by 32MHz oscillator.. Now I am debugging the board and change the NRF_SDH_CLOCK_LF_SRC,  NRFX_CLOCK_CONFIG_LF_SRC, CLOCK_CONFIG_LF_SRC to 1, NRF_SDH_CLOCK_LF_RC_CTIV to 16, NRF_SDH_CLOCK_LF_RC_TEMP_CTIV to 2,  NRF_SDH_CLOCK_LF_ACCURACY to 1. 

// <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
//==========================================================
#ifndef NRF_CLOCK_ENABLED
#define NRF_CLOCK_ENABLED 1
#endif
// <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
 
// <0=> RC 
// <1=> XTAL 
// <2=> Synth 
// <131073=> External Low Swing 
// <196609=> External Full Swing 

#ifndef CLOCK_CONFIG_LF_SRC
#define CLOCK_CONFIG_LF_SRC 0             // 1
#endif

// <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
//==========================================================
#ifndef NRFX_CLOCK_ENABLED
#define NRFX_CLOCK_ENABLED 1
#endif
// <o> NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
 
// <0=> RC 
// <1=> XTAL 
// <2=> Synth 
// <131073=> External Low Swing 
// <196609=> External Full Swing 

#ifndef NRFX_CLOCK_CONFIG_LF_SRC
#define NRFX_CLOCK_CONFIG_LF_SRC 0              // 1
#endif

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC 
// <1=> NRF_CLOCK_LF_SRC_XTAL 
// <2=> NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0                      // 1
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

// <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
 
// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 

#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 1                   // 7
#endif

The firmware version is 17.0.2 and the firmware code is modified from ble_app_uart__saadc_timer_driven__scan_mode from NORDIC PLAYGROUND in Github. 

Now the code can running into "saadc_callback" function and the timer works well. But I can't scan the advertising from the customized board with "nRF Connect" app on cell phone. What other parameters should I change? Any help will be appreciated. 

 

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
        uint16_t adc_value;
        uint8_t value[SAADC_SAMPLES_IN_BUFFER*2];
        uint16_t bytes_to_send;
     
        // set buffers
        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
						
        // print samples on hardware UART and parse data for BLE transmission
        printf("ADC event number: %d\r\n",(int)m_adc_evt_counter);
        for (int i = 0; i < SAADC_SAMPLES_IN_BUFFER; i++)
        {
            printf("%d\r\n", p_event->data.done.p_buffer[i]);

            adc_value = p_event->data.done.p_buffer[i];
            value[i*2] = adc_value;
            value[(i*2)+1] = adc_value >> 8;
        }

         // Send data over BLE via NUS service. Create string from samples and send string with correct length.
        uint8_t nus_string[50];
        bytes_to_send = sprintf(nus_string, 
                                "CH0: %d\r\nCH1: %d\r\nCH2: %d\r\nCH3: %d",
                                p_event->data.done.p_buffer[0],
                                p_event->data.done.p_buffer[1],
                                p_event->data.done.p_buffer[2],
                                p_event->data.done.p_buffer[3]);

        err_code = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);
        if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_NOT_FOUND))
        {
            APP_ERROR_CHECK(err_code);
        }
	NRF_LOG_INFO("Debug logging for UART over RTT started.");
        m_adc_evt_counter++;
    }
}

Parents
  • Thank you Jonathan. Yes, I can share anything to solve the problem. Here is the main part of nrf52832 in schematic. 

    How to check out if the device works when it comes to transmitting? I have an antenna for nrf52832 on board. But based on the previous nrf52832 project I did before, the missing of antenna will only affect the signal strength. The BLE network should set up between MCU and the phone and the signal will be weaker without the antenna. Hope to get help from you. Thanks.

Reply
  • Thank you Jonathan. Yes, I can share anything to solve the problem. Here is the main part of nrf52832 in schematic. 

    How to check out if the device works when it comes to transmitting? I have an antenna for nrf52832 on board. But based on the previous nrf52832 project I did before, the missing of antenna will only affect the signal strength. The BLE network should set up between MCU and the phone and the signal will be weaker without the antenna. Hope to get help from you. Thanks.

Children
No Data
Related