Hi. I'm writing my own libraries for nRF52832 and I can't get UARTE to work.
Here is my code.
I'm using pins 6 and 8 as the UART example.
I wrote same code for UART (without DMA) and it works fine!
uart.c file
#include <string.h> #include <stdbool.h> #include "nrf52.h" #include "uart.h" static volatile uint8_t tx_buffer[128]; void uart_set_baudrate(uint32_t val) { NRF_UARTE0->BAUDRATE = val; } void uart_configure(uint32_t parity, uint32_t hwfc) { NRF_UARTE0->CONFIG = (parity << UART_CONFIG_PARITY_Pos) | (hwfc << UART_CONFIG_HWFC_Pos); } void uart_set_pins(uint32_t txpin, uint32_t rxpin) { NRF_UARTE0->PSEL.RXD = rxpin; NRF_UARTE0->PSEL.TXD = txpin; } void uart_enable(void) { NRF_UARTE0->ENABLE = UART_ENABLE_ENABLE_Enabled; } void uart_init(void) { uart_set_baudrate(UART_BAUDRATE_BAUDRATE_Baud115200); uart_configure(UART_CONFIG_PARITY_Excluded, UART_CONFIG_HWFC_Disabled); uart_set_pins(6, 8); uart_enable(); } void uart_write_string(uint8_t * str, int size) { memcpy(tx_buffer, str, size); NRF_UARTE0->TXD.PTR = (uint32_t)((uint8_t *)tx_buffer); NRF_UARTE0->TXD.MAXCNT = size; NRF_UARTE0->TASKS_STARTTX = 1; }
main.c
int main(void) { clock_init(); rtc_init(); gpio_out_set(6); gpio_config_output(6); gpio_config_input(8, GPIO_PIN_CNF_PULL_Disabled); uart_init(); uart_write_string("Hello world\r\n", 14); radio_init(); __enable_irq(); while (true) { } }
I don't get anything on the terminal.