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

Why there are some pins cant be the ss pin of SPI

HI

I'm using SPI connecting to mutiple max31856(two now) on nrf52DK and SDK15.3

so I control my ss pin to pull low by myself 

chip select by changing spi_pin like some code below

void MAX31856_setThermocoupleType(max31856_thermocoupletype_t type ,uint32_t spi_pin)
{   
    nrf_gpio_pin_clear(spi_pin);
    MAX31856_write_reg(MAX31856_CR1_REG);
    uint8_t t = MAX31856_read_reg(0xFF);
    nrf_gpio_pin_set(spi_pin);

    t &= 0xF0; // mask off bottom 4 bits
    t |= (uint8_t)type & 0x0F;

    nrf_gpio_pin_clear(spi_pin);
    MAX31856_write_reg(MAX31856_CR1_REG|0x80);
    MAX31856_write_reg(t);
    nrf_gpio_pin_set(spi_pin);
}

my miso is 5, mosi is 7 , sck is 8

and ss1 is 6 , ss2 is 9 at first

then i found that ss1 works fine ,but ss2 doesnt

SO I TRY OTHER PINS, AND FOUND THAT pin 2,3,4,6,12,13,14,15,18,19,20,22,23,24,26,27,28,29,30,31 can work

BUT pin 9,10,11,13,17,21,25 cant work

MY QUESTION  is why that happened

thanks

Parents
  • Pin 9 is by default NFC.  To use it, you need to configure in the UICR register for that pin to act as GPIO.

        /* 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;
                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;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NVIC_SystemReset();
            }
        #endif
    

Reply
  • Pin 9 is by default NFC.  To use it, you need to configure in the UICR register for that pin to act as GPIO.

        /* 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;
                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;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NVIC_SystemReset();
            }
        #endif
    

Children
No Data
Related