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
  • For your information, I have tested code for both conditions means NRF_UART0->CONFIG=0 or NRF_UART0->CONFIG=1.

    When we set NRF_UART0->CONFIG=1 then that means unless you start serial terminal on PC side your code will not execute.... because we have enable flow control.

    And NRF_UART0->CONFIG=0 means microcontroller does not care whether serial terminal is activated or not on PC side.

Reply
  • For your information, I have tested code for both conditions means NRF_UART0->CONFIG=0 or NRF_UART0->CONFIG=1.

    When we set NRF_UART0->CONFIG=1 then that means unless you start serial terminal on PC side your code will not execute.... because we have enable flow control.

    And NRF_UART0->CONFIG=0 means microcontroller does not care whether serial terminal is activated or not on PC side.

Children
No Data
Related