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

nRF24LE1 PWM frequency setting

Hi,

I'm asking this becase it is not very clear about the PWM in Product Specification v1.6 for nRF24LE1
in the nRF24LE1_PS_v1.6.pdf mentioned the pwm Frequency-range from 4 kHz to 254 kHz (when MCU is clocked at 16 MHz), First, may i know what the pre-scale value we chose to get the 4 kHz and 254kHz?

second, what is the available value for PWMCON bit5-2: PWM frequency pre-scale factor , is it from 0~15 ? all the 16 values can be chose ?

Please kindly advise, thank you ~

Parents
  • Hi,

     

    First, may i know what the pre-scale value we chose to get the 4 kHz and 254kHz?

    4kHz: PWMCON (7:6) = 0b'11, and PWMCON[5:2]  = 15

    This gives 16M clk * 1 / (255 * (15+1) = ~4 kHz (generating an effective 2kHz pulse)

     

    254 kHz: 4kHz: PWMCON (7:6) = 0b'00, and PWMCON[5:2]  = 0

    16M * 1 / (31 * (0 + 1) = ~516 kHz (generating an effective ~258 kHz pulse)

     

    Quick test in firmware:

        // Fast
        #if 1
        PWMCON = 0x03;
        PWMDC0 = 15;
        // Slow
        #else
        PWMCON = 0xff;
        PWMDC0 = 127;
        #endif

     

    So, the documentation is incorrect, as the PWM peripheral itself will be between 4 kHz and 516 kHz, with an effective output frequency of between 2 kHz and 258 kHz.

    second, what is the available value for PWMCON bit5-2: PWM frequency pre-scale factor , is it from 0~15 ? all the 16 values can be chose ?

    As per the first picture you attached, you can set the prescaler from 0 to 15. You are free to choose any value between.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    First, may i know what the pre-scale value we chose to get the 4 kHz and 254kHz?

    4kHz: PWMCON (7:6) = 0b'11, and PWMCON[5:2]  = 15

    This gives 16M clk * 1 / (255 * (15+1) = ~4 kHz (generating an effective 2kHz pulse)

     

    254 kHz: 4kHz: PWMCON (7:6) = 0b'00, and PWMCON[5:2]  = 0

    16M * 1 / (31 * (0 + 1) = ~516 kHz (generating an effective ~258 kHz pulse)

     

    Quick test in firmware:

        // Fast
        #if 1
        PWMCON = 0x03;
        PWMDC0 = 15;
        // Slow
        #else
        PWMCON = 0xff;
        PWMDC0 = 127;
        #endif

     

    So, the documentation is incorrect, as the PWM peripheral itself will be between 4 kHz and 516 kHz, with an effective output frequency of between 2 kHz and 258 kHz.

    second, what is the available value for PWMCON bit5-2: PWM frequency pre-scale factor , is it from 0~15 ? all the 16 values can be chose ?

    As per the first picture you attached, you can set the prescaler from 0 to 15. You are free to choose any value between.

     

    Kind regards,

    Håkon

Children
Related