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

CAN I MODIFY UART TXD INTERRUPT FLAG? (SET NRF_UART0->EVENTS_TXDRDY to 1 in software)

Hello: I am using NRF51822 to design somethings. And I want to use interrupt send method instead of polling send method. NRF51822's UART0 provides TXDRDY interrupt. After serial output one frame, Hardware set TXDRDY to 1, and then program goes into INTERRUPT. My question is: TXDRDY only can be set by HW? Can I modify this flag in software? Besides, in nRF51_Reference_manual v1.1.pdf, page 30th, Figure 4, status of EVENT m can be modified by both peripheral core and CPU write. Whether "CPU write" means that we can change it manully?

If this flag can be modified, when we want to transmitting a frame, process like below, advantage is that when and How the contents will be transfered I do not care, interrupt program will complete it. what I need to do is put data.

Example 1: char sendc(u8 c) { CLEAR_WDT();

// if sending buffer is full,  suspend and wait.
while (UART_SEND_BUF_SIZE == g_uart_param.send.bytes);

__disable_irq(); 

g_uart_param.send.buf[g_uart_param.send.write_index++] = c;
g_uart_param.send.bytes++;
if (g_uart_param.send.write_index >= UART_SEND_BUF_SIZE){
	g_uart_param.send.write_index = 0;
}

if (1 == g_uart_param.send.bytes && g_uart_param.tx_transmited){
	
            // set sending buffer flag to 1, then goes into interrupt after enable irq.
	NRF_UART0->EVENTS_TXDRDY = 1;
}

__enable_irq();

return c;
}

Similiar usage is 51 sending interrupt, flag TI in SCON means transmitting over, but we can set TI to 1 manully, then program goes into interrupt.

I've test example 1, it can not goes into interrupt. If you have not understand my words, I can upload my UART code in reply.
Related