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

is PSEL register setting for resp. peripheral automatically configure IO pin setting ?

#include "nrf_delay.h"
#include "nrf_gpio.h"

void uart_init()
{
   
     NRF_UART0->BAUDRATE = 0x01D7E000;
     NRF_UART0->CONFIG = 0x00000001;

     NRF_UART0->PSELRTS = 5;
     NRF_UART0->PSELTXD = 6;
     NRF_UART0->PSELCTS = 7;
     NRF_UART0->PSELRXD = 8;
    
//     nrf_gpio_cfg_output(6);
//     nrf_gpio_cfg_input(8, GPIO_PIN_CNF_PULL_Disabled);
// 
//     nrf_gpio_cfg_output(5);
//     nrf_gpio_cfg_input(7, GPIO_PIN_CNF_PULL_Disabled);

    NRF_UART0->ENABLE = 0x00000004;
    
    NRF_UART0->TASKS_STARTTX = 1;

}

void uart_write(unsigned char data)
{
    NRF_UART0->TXD = data;
        
    while(NRF_UART0->EVENTS_TXDRDY==0){}

    NRF_UART0->EVENTS_TXDRDY = 0; 

}

int main(void)
{
  NRF_P0->DIR |= 0x000E0000;
  NRF_P0->OUTSET |= 0x000E0000;
  
  uart_init();

  while(1) 
  {
 
    NRF_P0->OUT^=0x00080000;
     
    uart_write('@');
    
    nrf_delay_ms(100);

  }
}

This is working code for uart transmitter using direct register access. My question : is PSEL register setting for resp. peripheral automatically configure IO pin setting ?

As per my board pins. 5,6,7,8 are connected to RTS, TXD, CTS, RXD resp. to CP2101. So is it necessary to configure pins 5,6,7,8 for input, output, pull-up, pull-down OR PSEL setting automatically takes care of it ??

Because even after I comment out IO setting , there is no effect on working.

Excuse me for my English !!

Parents
  • You can chose to override the default GPIO settings used by the UART. It can be useful if you need to change the drive strength on the GPIOs for example. I saw a similar case not long ago. That was about TWI, but is relevant for the UART too:

    "I talked to one of our HW architects and he said that the GPIO settings actually do influence the pin even when the TWI is enabled. In other words, changing the drive strength from S0D1 to S0S1 will have an effect on the TWI bus. [...]"

Reply
  • You can chose to override the default GPIO settings used by the UART. It can be useful if you need to change the drive strength on the GPIOs for example. I saw a similar case not long ago. That was about TWI, but is relevant for the UART too:

    "I talked to one of our HW architects and he said that the GPIO settings actually do influence the pin even when the TWI is enabled. In other words, changing the drive strength from S0D1 to S0S1 will have an effect on the TWI bus. [...]"

Children
No Data
Related