#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 !!