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

nRF52832 UARTE basics with terminal communication - receiving no data

Hi, I'm having problem with UART communication. I use basic UARTE code and I want to send simple data to PuTTy terminal. The problem is whatever I would send i get only 'K' in my terminal and no data at all. I attach my code and screenshot from PuTTy. Terminal configuration seems to be fine. I get "Kb" if I try to send more than 1 byte. Thanks for your help in advance Slight smile

PS. I'm using SiliconLabs CP210x chip for uart-usb conversion.

#include <nrf.h>

#define PIN_GPIO_OUTPUT (7)
#define PIN_GPIO_INPUT (6)

#define PIN_TXD (12)
#define PIN_RXD (11)

static volatile uint8_t counter = 0;

int main(void)
{
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;


NRF_GPIO->PIN_CNF[PIN_GPIO_OUTPUT] = 0x01;
NRF_GPIO->PIN_CNF[PIN_GPIO_INPUT] = 0x0C;

NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_32Bit << TIMER_BITMODE_BITMODE_Pos;
NRF_TIMER0->PRESCALER = 8 << TIMER_PRESCALER_PRESCALER_Pos; //2us
NRF_TIMER0->CC[0] = 62500;
NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos;
NRF_TIMER0->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos;

uint32_t value = 0000;


// Configure the UARTE with no flow control, one parity bit and 115200 baud rate
NRF_UARTE0->CONFIG = (UART_CONFIG_HWFC_Disabled << UART_CONFIG_HWFC_Pos) |
(UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos);

NRF_UARTE0->BAUDRATE = UARTE_BAUDRATE_BAUDRATE_Baud9600 << UARTE_BAUDRATE_BAUDRATE_Pos;

// Select TX and RX pins
NRF_UARTE0->PSEL.TXD = PIN_TXD;
NRF_UARTE0->PSEL.RXD = PIN_RXD;

// Enable the UART (starts using the TX/RX pins)
NRF_UARTE0->ENABLE = UARTE_ENABLE_ENABLE_Enabled << UARTE_ENABLE_ENABLE_Pos;

// Configure transmit buffer and start the transfer
NRF_UARTE0->TXD.MAXCNT = 1;
NRF_UARTE0->TXD.PTR = (uint32_t)&value;


NRF_GPIO->OUTSET = (1<<PIN_GPIO_OUTPUT);

NVIC_EnableIRQ(TIMER0_IRQn);
NRF_TIMER0->TASKS_START = 1;
// Toggle GPIO ON/OFF.

while (1)
{


}

}

// This IRQ handler will trigger every 1000us
void TIMER0_IRQHandler(void)
{
volatile uint32_t dummy;
counter++;

NRF_UARTE0->TASKS_STARTTX = 1;

// Wait until the transfer is complete
while (NRF_UARTE0->EVENTS_ENDTX == 0)
{
}

if (counter%2 == 0)
NRF_GPIO->OUTCLR = (1<<PIN_GPIO_OUTPUT);
else NRF_GPIO->OUTSET = (1<<PIN_GPIO_OUTPUT);

if (NRF_TIMER0->EVENTS_COMPARE[0] == 1)
{
NRF_TIMER0->EVENTS_COMPARE[0] = 0;

// Read back event register so ensure we have cleared it before exiting IRQ handler.
dummy = NRF_TIMER0->EVENTS_COMPARE[0];
dummy; // to get rid of set but not used warning
}
if (counter>50)
counter = 0;
}

Parents Reply Children
No Data
Related