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

nrf52833 P0.0 will output high level strangely

SDK17.0.2+NRF52833

I use nrf52833 to do some thing, P1.09 and p0.11 as two pwm singals to drive two motor and P0.0 as a led pin (high made led light).

the code as following:

static void pwm0_init(void)
{

    uint32_t err_code;
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {

            MOTOR_CTRL_PIN_0 | NRF_DRV_PWM_PIN_INVERTED, //P1.09
            MOTOR_CTRL_PIN_1 | NRF_DRV_PWM_PIN_INVERTED, //P0.11
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_500kHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = PWM_TOP_VALUE,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
    APP_ERROR_CHECK(err_code);
    m_used |= USED_PWM(0);
    //board_light_red();

    m_pwm_seq_values.channel_0 = 0;
    m_pwm_seq_values.channel_1 = 0;

    nrf_drv_pwm_simple_playback(&m_pwm0, &m_pwm_seq, 1, NRF_DRV_PWM_FLAG_LOOP);//why execute this, the P0.0 output high level.
}

void motor_ctrl_init(void)
{
	

    uint8_t i = 0;
	uint32_t motor_ctrls[] = MOTOR_PINS_LIST;
	for (i = 0; i < MOTOR_CTRLS_NUMBER; i++)
	{
		nrf_gpio_cfg_output(motor_ctrls[i]);
        nrf_gpio_pin_write(motor_ctrls[i],0);
	}
    pwm0_init();

	NRF_LOG_DEBUG("%s return ok.\n", __FUNCTION__);
}

int main(void)
{

	uint32_t err_code;
    
	log_init();
	NRF_LOG_INFO("apps start......");
	motor_ctrl_init();
	///...
}

I want light the LED after pwm init. but the led(connected P0.0)lighted before my code to output the p0.0 high level-when the pwm0_init function executed. It's not match my desire.

additional: Softdevice burninged(s140_nrf52_7.2.0_softdevice.hex)

Parents
  • Hi P0.00 (and P0.01) is by default in our examples used by the external 32.768 kHz LF crystal which is present on our DKs, but not on most 3rd party modules and might not be used on your HW. If you'd like to use the P0.00 as a normal GPIO, you need to configure your device to use the internal RC oscillator. This can be done by changing the following defines to these values in your sdk_config.h file.

    // <h> Clock - SoftDevice clock configuration
    
    //==========================================================
    // <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
    #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
    #endif

    Best regards,

    Simon

  • my settings of these macros is same as yours. We have found use keil to compile there exist this question(P0.0 output high strangly), but use ses compile is ok. It's confused us.

Reply Children
Related