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

Enabling UART disables the Radio

Hi,

I am using the nRF52832 and am going at it barebones because I cannot for the life of me get the SDK to work. I am using the nRF52832 manual.

-> Manual

I have two boards and I have them configured one as transmitter and one as receiver.

Receiver Initialization:

NRF_CLOCK->TASKS_HFCLKSTART = 1; 
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

NRF_RADIO->POWER = 1; /* Turn the radio on */
NRF_RADIO->MODE = RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos; /* BLE mode */
NRF_RADIO->PCNF0 = 0; /* no S0, S1 or length fields. 8-bit preamble. */
NRF_RADIO->PCNF1 = (16 << RADIO_PCNF0_LFLEN_Pos) | /* Packet Length */
(16 << RADIO_PCNF1_STATLEN_Pos) | /* Static Length Parameter in number of Bytes */
(2 << RADIO_PCNF1_BALEN_Pos) | /* Base Address Length in number of Bytes */
(RADIO_PCNF1_ENDIAN_Little << RADIO_PCNF1_ENDIAN_Pos) | /* Little Endian */
(RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos); /* Enable Packet whitening? */
NRF_RADIO->DATAWHITEIV = 0x55; /* Init whitening value */

NRF_RADIO->BASE0 = 0x0000BABE; /* Configure BASE0 */
NRF_RADIO->PREFIX0 = 0x41 << RADIO_PREFIX0_AP0_Pos; /* Configure Prefix0 */

NRF_RADIO->RXADDRESSES = RADIO_RXADDRESSES_ADDR0_Enabled << RADIO_RXADDRESSES_ADDR0_Pos; /* Use Logical Address (BASE0 + PREFIX0 byte 0)*/


NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos) | /* Initialize CRC (two bytes) */
(RADIO_CRCCNF_SKIPADDR_Skip << RADIO_CRCCNF_SKIPADDR_Pos);
NRF_RADIO->CRCPOLY = 0x0000AAAA;
NRF_RADIO->CRCINIT = 0x12345678;

NRF_RADIO->MODECNF0 = (RADIO_MODECNF0_DTX_B0 << RADIO_MODECNF0_DTX_Pos) | /* Enable Fast Ramp Up */
(RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos);

NRF_RADIO->FREQUENCY = 0 << RADIO_FREQUENCY_FREQUENCY_Pos; /* receiving/sending packets at 2400MHz */

NRF_RADIO->PACKETPTR = (uint32_t)&packet[0]; /* Configure address of the packet and logic address to use */

NRF_RADIO->SHORTS = (RADIO_SHORTS_READY_START_Enabled << RADIO_SHORTS_READY_START_Pos) | /* Configure shortcuts to start as soon as READY event is received, and disable radio as soon as packet is received. */
(RADIO_SHORTS_END_DISABLE_Enabled << RADIO_SHORTS_END_DISABLE_Pos);

Transmitter Initialization:

NRF_CLOCK->TASKS_HFCLKSTART = 1; /* Start the HFCLK from crystal oscillator. */
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

NRF_RADIO->POWER = 1; /* Turn the radio on */

NRF_RADIO->MODE = RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos; /* configure for BLE mode */

NRF_RADIO->PCNF0 = 0; /* No S0, S1, or Length fields. 8-bit preamble */
NRF_RADIO->PCNF1 = (16 << RADIO_PCNF1_MAXLEN_Pos) | /* Packet Length */
(16 << RADIO_PCNF1_STATLEN_Pos) | /* Static Length Parameter in number of Bytes */
(2 << RADIO_PCNF1_BALEN_Pos) | /* Base Address Length in number of Bytes */
(RADIO_PCNF1_ENDIAN_Little << RADIO_PCNF1_ENDIAN_Pos) | /* Little Endian */
(RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos); /* Enable Packet whitening? */

NRF_RADIO->DATAWHITEIV = 0x55; /* Init whitening value*/

NRF_RADIO->BASE0 = 0x0000BABE; /* Configure Base0 */
NRF_RADIO->PREFIX0 = 0x41 << RADIO_PREFIX0_AP0_Pos; /* Configure Address prefix */

NRF_RADIO->TXADDRESS = 0 << RADIO_TXADDRESS_TXADDRESS_Pos; /* Use logical address 0 (BASE0 + PREFIX byte 0)*/

NRF_RADIO->MODECNF0 = (RADIO_MODECNF0_DTX_B0 << RADIO_MODECNF0_DTX_Pos) | /* Enable fast rampup, new in nRF52 */
(RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos);

NRF_RADIO->TXPOWER = RADIO_TXPOWER_TXPOWER_Pos4dBm << RADIO_TXPOWER_TXPOWER_Pos; /* 4dBm output power, sending packets at 2400MHz */
NRF_RADIO->FREQUENCY = 0 << RADIO_FREQUENCY_FREQUENCY_Pos;

NRF_RADIO->PACKETPTR = (uint32_t)&packet[0]; /* Configure address of the packet and logic address to use */

NRF_RADIO->SHORTS = (RADIO_SHORTS_READY_START_Enabled << RADIO_SHORTS_READY_START_Pos) | /* Configure shortcuts to start as soon as READY event is received, and disable radio as soon as packet is sent. */
(RADIO_SHORTS_END_DISABLE_Enabled << RADIO_SHORTS_END_DISABLE_Pos);

When I try to enable UART (which I know works because I got it working on its own), the receiver just doesn't work. I toggle an LED for when each is transmitting/receiving. The LED on the receiver never toggles. Is there something about using the radio and UART0 together that doesn't work?

UART init for completeness:

NRF_P0->PIN_CNF[27] = 0x02 | 0x01;
NRF_P0->DIRSET |= GPIO_PIN27_Msk;
NRF_P0->OUTSET |= GPIO_PIN27_Msk;
NRF_P0->PIN_CNF[26] = 0;
NRF_P0->DIRCLR |= GPIO_PIN26_Msk;
NRF_P0->OUTCLR |= GPIO_PIN26_Msk;

NRF_UARTE0->ENABLE = 0; /* Disable UARTE0 */

NRF_UART0->PSELTXD &= ~GPIO_PIN27_Msk;
NRF_UART0->PSELRXD &= ~GPIO_PIN26_Msk;
NRF_UART0->BAUDRATE = UART_Baud9600;
NRF_UART0->CONFIG = 0;
NRF_UART0->ENABLE = 0x04;

Parents Reply Children
Related