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
  • Hi,

    Take a look at this example in the SDK: C:\Nordic Semiconductor\nRF51 SDK_v4.3.0.27417\Nordic\nrf51822\Board\nrf6310\twi_sw_master_example

    The pin definition is shown in file "twi_master_config.h". This example uses a bit banged TWI, but if you switch that file with "twi_hw_master.c" instead, then you use the HW peripheral instead.

    The pin selection is done on these two lines: NRF_TWI1->PSELSCL = TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER; NRF_TWI1->PSELSDA = TWI_MASTER_CONFIG_DATA_PIN_NUMBER;

    The defines are basically a GPIO number (between 0 - 30). These two GPIOs will then be controlled by the TWI HW module until you disable the TWI.

  • Thanks! In the meantime, through that example I managed to get the pins defined -- those commands are done for me in the twi_master_init routine. I do see a logic high on both pin 24 and 25 (which is good!) but no toggling (looking at it with a scope) on them when I try to run the following in main():

    static uint8_t m_device_address;
    const uint8_t blah = 0x17;
    m_device_address = 0x00 + (uint8_t)(0x39 
    
Reply
  • Thanks! In the meantime, through that example I managed to get the pins defined -- those commands are done for me in the twi_master_init routine. I do see a logic high on both pin 24 and 25 (which is good!) but no toggling (looking at it with a scope) on them when I try to run the following in main():

    static uint8_t m_device_address;
    const uint8_t blah = 0x17;
    m_device_address = 0x00 + (uint8_t)(0x39 
    
Children
No Data
Related