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

How I can control Pin0.8 Pin0.9 as PWM Channel to output PWM wave I want?

I reference demo1 of PWM driver example in SDK15.2.0, I make myself PWM driver. the official demo1 use pin17-20 as PWM channal1-channel4, but I use Pin9-P12, I modify the config file, like follow
//official configure
#define LED_START 17
#define LED_1 17
#define LED_2 18
#define LED_3 19
#define LED_4 20
#define LED_STOP 20
//my configure
#define LED_START 9
#define LED_1 9
#define LED_2 10
#define LED_3 11
#define LED_4 12
#define LED_STOP 12

then I use following the code to make the PWM on every channel, like this:

    m_demo1_seq_values.channel_0 = 1000; 

    m_demo1_seq_values.channel_1 = 3000;

    m_demo1_seq_values.channel_2 = 5000;

    m_demo1_seq_values.channel_3 = 7000;


when I run the new image file on nrf52832 on my board(different to Pca10040), I find the Pin10 and Pin12 can output the PWM I want, But Pin9 and Pin10 do nothing, This makes me confused, I believe Pin9 and P10 are less different than Pin11 and Pin12, but why Pin9 and Pin10 don't output PWM I want. How I fix this issue?

Parents
  • Pins 9 and 10 actually default to NFC pins, so must be reverted to i/o pins before they will be useful on your design. Typically you can do this by defining CONFIG_NFCT_PINS_AS_GPIOS in your project options; this code in system_nrf52.c then puts the pins into the i/o mode.

    void SystemInit(void)
    {
    
        /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
           two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
           normal GPIOs. */
        #if defined (CONFIG_NFCT_PINS_AS_GPIOS)
            if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; // Write Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; // Read-only Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                // UICR changes require a reset to be effective
                NVIC_SystemReset();
            }
        #endif

  • thank guys, the reason just is that. I already control the PINS.

Reply Children
No Data
Related