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

Assigning a functional block to a GPIO

I'm confused about how to assign a functional block's I/O (TWI in my case) to a particular pin on the device. Is there a worked and documented example? Is there a relevant application note?

Parents
  • I've narrowed it down to the chip getting stuck when I call this function (it's unmodified from the example code):

    bool twi_master_init(void)
    {
        /* To secure correct signal levels on the pins used by the TWI
           master when the system is in OFF mode, and when the TWI master is 
           disabled, these pins must be configured in the GPIO peripheral.
        */
        NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER] = 
            (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
          | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
          | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
          | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
          | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos);    
    
        NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_DATA_PIN_NUMBER] = 
            (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
          | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
          | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
          | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
          | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos);    
    
        NRF_TWI1->EVENTS_RXDREADY = 0;
        NRF_TWI1->EVENTS_TXDSENT = 0;
        NRF_TWI1->PSELSCL = TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER;
        NRF_TWI1->PSELSDA = TWI_MASTER_CONFIG_DATA_PIN_NUMBER;
        NRF_TWI1->FREQUENCY = TWI_FREQUENCY_FREQUENCY_K100 << TWI_FREQUENCY_FREQUENCY_Pos;
        NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TWI1->EVENTS_BB;
        NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TWI1->TASKS_SUSPEND;
        NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Msk;
        NRF_TWI1->ENABLE = TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos;
    
        return twi_master_clear_bus();
    }
    

    What I see is the pins going high, as they should, but nothing more. What am I missing?

Reply
  • I've narrowed it down to the chip getting stuck when I call this function (it's unmodified from the example code):

    bool twi_master_init(void)
    {
        /* To secure correct signal levels on the pins used by the TWI
           master when the system is in OFF mode, and when the TWI master is 
           disabled, these pins must be configured in the GPIO peripheral.
        */
        NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER] = 
            (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
          | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
          | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
          | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
          | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos);    
    
        NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_DATA_PIN_NUMBER] = 
            (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
          | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos)
          | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)
          | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos)
          | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos);    
    
        NRF_TWI1->EVENTS_RXDREADY = 0;
        NRF_TWI1->EVENTS_TXDSENT = 0;
        NRF_TWI1->PSELSCL = TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER;
        NRF_TWI1->PSELSDA = TWI_MASTER_CONFIG_DATA_PIN_NUMBER;
        NRF_TWI1->FREQUENCY = TWI_FREQUENCY_FREQUENCY_K100 << TWI_FREQUENCY_FREQUENCY_Pos;
        NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TWI1->EVENTS_BB;
        NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TWI1->TASKS_SUSPEND;
        NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Msk;
        NRF_TWI1->ENABLE = TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos;
    
        return twi_master_clear_bus();
    }
    

    What I see is the pins going high, as they should, but nothing more. What am I missing?

Children
No Data
Related