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

How Can I Multiple Pins Configurated

I try multiple pins set. My pro code is here. 

//unsigned char sutunlar;

void Sutun_Cikislari(void)
{
  nrf_gpio_cfg_output(LED_DENEME);
//  sutunlar = NRF_GPIO->DIRSET & ((1UL << SUTUN_1) | (1UL << SUTUN_2) | (1UL << SUTUN_3));
  nrf_gpio_cfg_output(SUTUN_1);
  nrf_gpio_cfg_output(SUTUN_2);
  nrf_gpio_cfg_output(SUTUN_3);
  nrf_gpio_pin_set(SUTUN_1);
  nrf_gpio_pin_set(SUTUN_2);
  nrf_gpio_pin_set(SUTUN_3);
//  nrf_gpio_pin_set(sutunlar);
  nrf_gpio_cfg_input(SATIR_1, NRF_GPIOTE_POLARITY_LOTOHI);
  nrf_gpio_pin_read(SATIR_1);
  nrf_gpio_cfg_input(SATIR_2, NRF_GPIOTE_POLARITY_LOTOHI);
  nrf_gpio_pin_read(SATIR_2);

But this is not clear. I want to decrease my code line. Then I tried this.

//unsigned char sutunlar;

void Sutun_Cikislari(void)
{
  nrf_gpio_cfg_output(LED_DENEME);
  sutunlar = NRF_GPIO->DIRSET & ((1UL << SUTUN_1) | (1UL << SUTUN_2) | (1UL << SUTUN_3));
//  nrf_gpio_cfg_output(SUTUN_1);
//  nrf_gpio_cfg_output(SUTUN_2);
//  nrf_gpio_cfg_output(SUTUN_3);
//  nrf_gpio_pin_set(SUTUN_1);
//  nrf_gpio_pin_set(SUTUN_2);
//  nrf_gpio_pin_set(SUTUN_3);
  nrf_gpio_pin_set(sutunlar);
  nrf_gpio_cfg_input(SATIR_1, NRF_GPIOTE_POLARITY_LOTOHI);
  nrf_gpio_pin_read(SATIR_1);
  nrf_gpio_cfg_input(SATIR_2, NRF_GPIOTE_POLARITY_LOTOHI);
  nrf_gpio_pin_read(SATIR_2);

I want to know where is my mistake?

Parents
  • Hi!

    I'm not quite sure what you are trying to acheive here, and what your problem is.
    Have you tried debugging to find out where you are running into any errors?

    You could start by uncommenting the "unsigned char sutunlar;" and changing it to a "uint32_t sutunlar;" instead.

    nrf_gpio_pin_set(sutunlar) won't work. This function expects a single pin number as a input.

    Try using;
    NRF_GPIO->OUTSET = sutunlar;
    instead.

    Let me know if this helps, or if you need further assistance.

    Best regards,
    Joakim

Reply
  • Hi!

    I'm not quite sure what you are trying to acheive here, and what your problem is.
    Have you tried debugging to find out where you are running into any errors?

    You could start by uncommenting the "unsigned char sutunlar;" and changing it to a "uint32_t sutunlar;" instead.

    nrf_gpio_pin_set(sutunlar) won't work. This function expects a single pin number as a input.

    Try using;
    NRF_GPIO->OUTSET = sutunlar;
    instead.

    Let me know if this helps, or if you need further assistance.

    Best regards,
    Joakim

Children
Related