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

UARTE configuration with nrf9160 and zephyr

Hi,

we have developed our working UART code according to Zephyr documentation, and its working fine,

we find that this code works with EasyDMA . but my question is my uart2_fifo_callback function is calling for every byte, why its happening like this, please help me to understand?

Note: we are using UART in UARTE_INTERRUPT_DRIVEN mode

and some other doubts are:

1. How we can increase/decide RX FIFO size

2. How we can configure UART so that the Uart_fifo_callback function will be called only once per every communication

3. What is the difference between UARTE_INTERRUPT_DRIVEN and CONFIG_UART_ASYNC_API, can we have interrupt handler even if i use CONFIG_ASYNC_API mode?

Best Regards

Rajener.

  • Hi,

    after spending some time on this i got to know that

    when i transmit data using uart_tx() this will return 0, (means-successful) but again it will trigger timeout function(static void tx_timeout()) then, UART_TX_ABORTED event, and then UART_TX_DONE event.
    but anyway data will not sends to the UART Terminal.

    Please help me to solve this.

    NOTE: I am attaching my project for your reference please check.

    UART_TEST.zip

    Best Regards

    Rajender.

  • Hi Rajender

    In order to configure pins and baudrate it is best to create an overlay file, which overwrites the default configuration for the UART_2 peripheral from dts. 

    This case describes how to create the overlay file for the UART peripheral on the nRF9160:
    https://devzone.nordicsemi.com/f/nordic-q-a/65473/uart-gpio-configuration

    Can you try this and see if you can spot any activity on the pins?

    If you are still having issues can you share the overlay file with me, and I will try to reproduce it on my end. 

    Best regards
    Torbjørn

  • Hi,

    we are using a custom board based on nrf9160,

    I found my .dts file in my zephyr/boards/arm/"board name", i figured out my default pinout and baud rate and all for my UART_2,

    that's why my rx interrupt is working properly and i can read the data properly

    but my present problem is (TX) i am not able to send any data from my controller, but i can receive properly.

    I have added This api to transmit

    int rett = uart_tx(dev_uart,read_ptr,read_len,1000);

    and when i deep dive in further,  i found that in below function its going into "else " statement only which is error message: Unknown ARM architecture.

    static ALWAYS_INLINE unsigned int arch_irq_lock(void)
    {
    	unsigned int key;
    
    #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
    	__asm__ volatile("mrs %0, PRIMASK;"
    		"cpsid i"
    		: "=r" (key)
    		:
    		: "memory");
    #elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
    	unsigned int tmp;
    
    	__asm__ volatile(
    		"mov %1, %2;"
    		"mrs %0, BASEPRI;"
    		"msr BASEPRI, %1;"
    		"isb;"
    		: "=r"(key), "=r"(tmp)
    		: "i"(_EXC_IRQ_DEFAULT_PRIO)
    		: "memory");
    #elif defined(CONFIG_ARMV7_R)
    	__asm__ volatile(
    		"mrs %0, cpsr;"
    		"and %0, #" TOSTR(I_BIT) ";"
    		"cpsid i;"
    		: "=r" (key)
    		:
    		: "memory", "cc");
    #else
    #error Unknown ARM architecture
    #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
    
    	return key;
    }

    Please help me

    Best Regards

    Rajender

  • Hi Rajender

    Have you tested the code on an nRF9160DK to see if the problem is the same?

    Are you able to share the board files for your board with me, and also a schematic of the board if you have one?

    If you want I can make the case private, in case you don't want to share your files in a public case. 

    Best regards
    Torbjørn

  • Hi

    Yes, the problem is in board files only, but these board files used to work fine without any extra hardware in INTERRUPT_DRIVEN_MODE

    finally now my TX and Rx both are working, after little bit modification in board files->uart config

    i have changed my board files like this...

    &uart2 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <11>;
    	rx-pin = <10>;
    	rts-pin = <12>;
    	cts-pin = <7>;
    	/*hw-flow-control;*/
    };

    Now my UARTE configuration is like this, and its working fine

    Prior to this The "hw-flow-control" was not in comment so then only RX used to work when i comment "hw-flow-control" now its working with both RX and TX.

    Best Regards

    Rajender

Related