This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cannot set the RTS_PIN_NUMBER

HI,ALL, I want to take use of hardware flow control, but when i set or clear the RTS signal, it failed. something about the attempt as following: the purpose:enable the hardware flow control,and disable the communication through the uart,that's means i should change the RTS signal in the project.

the version of sdk: 0.9.2

the board:nrf52382

the operation: first,I added such satement with print the pin status, in the main , after [printf("%s",start_string);] and before [err_code = ble_advertising_start(BLE_ADV_MODE_FAST).]

#################################################### printf("%s",start_string); while(1) { printf("++++++++++++++++++++++\r\n"); pin_status = nrf_gpio_pin_read( RTS_PIN_NUMBER); printf("before:%d\r\n",pin_status);

	nrf_gpio_pin_write(RTS_PIN_NUMBER,1);
	
	pin_status = nrf_gpio_pin_read( RTS_PIN_NUMBER);
	printf("after:%d\r\n",pin_status);
	
	nrf_gpio_pin_set(RTS_PIN_NUMBER);
	
	pin_status = nrf_gpio_pin_read( RTS_PIN_NUMBER);
	printf("after:%d\r\n",pin_status);
	
	nrf_gpio_pin_clear(RTS_PIN_NUMBER);
	
	pin_status = nrf_gpio_pin_read( RTS_PIN_NUMBER);
	printf("after:%d\r\n",pin_status);
	nrf_delay_ms(1000);
}
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);

####################################################

the message always shows the same echo on the PC software: ++++++++++++++++++++++ before:0 after:0 after:0 after:0 ++++++++++++++++++++++ before:0 after:0 after:0 after:0 ++++++++++++++++++++++ before:0 after:0 after:0 after:0

then i found there may be a function can set it ,then i added the satement like this #################################################### nrf_gpio_cfg_output(p_config->pselrts); nrf_gpio_pin_clear(p_config->pselrts); nrf_gpio_cfg_input(p_config->pselcts, NRF_GPIO_PIN_NOPULL); nrf_uarte_hwfc_pins_set(NRF_UARTE0, p_config->pselrts, p_config->pselcts); ####################################################

or

####################################################

        nrf_gpio_cfg_output(p_config->pselrts);
        nrf_gpio_pin_clear(p_config->pselrts);
        nrf_gpio_cfg_input(p_config->pselcts, NRF_GPIO_PIN_NOPULL);
        nrf_uarte_hwfc_pins_set(NRF_UART0, p_config->pselrts, p_config->pselcts);

####################################################

it's failed again.

  • You can't get state of the output pin using nrf_gpio_pin_read().

    Here is my code:

    #define get_outpin_state(pin) ((NRF_GPIO->OUT >> pin) & 1UL)
    
    while (1) 
    {
        printf("++++++++++++++++++++++\r\n");
        printf("before:%d\r\n", get_outpin_state(RTS_PIN_NUMBER));
    
        nrf_gpio_pin_write(RTS_PIN_NUMBER, 1);
        printf("after:%d\r\n", get_outpin_state(RTS_PIN_NUMBER));
    
        nrf_gpio_pin_set(RTS_PIN_NUMBER);
        printf("after:%d\r\n", get_outpin_state(RTS_PIN_NUMBER));
    
        nrf_gpio_pin_clear(RTS_PIN_NUMBER);
        printf("after:%d\r\n", get_outpin_state(RTS_PIN_NUMBER));
        nrf_delay_ms(1000);
    }
    

    Good luck to you.

Related