This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1310: UART PEEK/number of bytes available in FIFO option not available

Part Number: CC1310

Hi forum

Can i peek the number of bytes available in uart fifo...without having the need to call uart read???..this capability i wish if available will solve a problem i have been facing for months now...so much so that i am willing to interface an external UART with my CC1310 if i have to.I just want to peek my state of the FIFO and decide on my own if i want to read those available bytes or not...this capability is very common in contemporary systems..as the driver claims that the UART has been implemented using a ring buffer...so I should be able to know the state of the ring buffer at any given time and copy any number of bytes available in the FIFO whenever I want.If I don't read the said number of bytes in a timely fashion and the bytes keep coming over UART..i should see an overflow...unfortunately i have not been able to get it done on CC1310...please help

Best Regards

Ali

  • Hello Ali,

    Are you asking for the peek feature int the UART FIFO (in hardware) or the Ring buffer of UART TI-Driver (in software)? If you are asking for the peek feature in the UART FIFO then we don't have this feature.

    If you want to peek into the Ring fuffer of the UART TI-Driver, then I believe you can use the "UART_control" API with the parameter "cmd" set to "UART_CMD_PEEK".

    Hope this information helps!

    Thanks,
    Sai
  • Hi mate!

    Thank you for your response...ok so if i use the command shared by you,it will return the number of bytes available in my ring buffer???..if yes then can i memcpy those available bytes from that location to any location in memory for processing those bytes?

    How can i read those bytes???...

    Sat for example i peek and find 10 bytes...can i then issue a uart read with expected bytes 10 and get all those bytes in a buffer of my choice?

    Ali

  • Hello Ali,

    Please refer to the TI Drivers Runtime APIs Guide for more information on the APIs.

    Thanks,

    Sai

  • Hi sai!
    UART control doesnt implement UART CMD PEEK and UART GET RX COUNT in the drivers APIs...please advise
    Regards
    Alo
  • Hi

    Looking forward for your kind reply

    Ali

  • Hi sai

    It is a kind reminder and request to please look into my matter..

    Best regards

    Ali

  • Hi

    Still waiting

    Regards

    Ali

  • Hello Ali,

    Apologize for the delay in response!

    I see the issue. The implementation of "UART_CMD_PEEK" and "UART_CMD_GETRXCOUNT" is present in the driver "./simplelink_cc13x0_sdk_3_10_00_11/source/ti/drivers/uart/UARTCC26X0.c", but the examples in the SDK are using the driver "./simplelink_cc13x0_sdk_3_10_00_11/source/ti/drivers/uart/UARTCC26XX.c" where this implementation is not present.

    I am trying to understand if it is safe to switch to UARTCC26X0 driver. I will try to get back early next week with an answer.

    Thanks,
    Sai
  • No problem at all...i will be eagerly looking forward

    Yes you are right the UARTCC26X0 driver has all the implementations...i have not tried upgrading UARTCC26XX.c with UARTC26X0.c...i will wait for your expert guidance

    Best regards

    Ali

  • Hi sai!

    Looking forward for help...

    Best regards

    Alo

  • Hello Ali,

    Talking to one of my colleagues, the recommendation is for the application to read the UART data and then use it or discard it. The "./simplelink_cc13x0_sdk_3_10_00_11/source/ti/drivers/uart/UARTCC26X0.c" driver is not designed to be power efficient and hence it's not used with the examples provided with the SDK.

    If your system does not require low-power then you can switch to using the "UARTCC26X0" driver.

    I haven't tried this so far, but to switch to using "UARTCC26X0" driver, you will need to modify the ".fxnTablePtr" element of "UART_config" structure in the board file (CC1310_LAUNCHXL.c) of you example/application.

    Hope this helps!

    Regards,
    Sai
  • Hi sai!
    Alright since my application doesnot require low power so i might use it without a problem but i donot exactly know how to modify the fxn table...can you help me do it?
    Regards
    Ali
  • My application needs to know the exact amount of data in the uart buffer before issuing a uart read call therefore i really need to switch to UARTCC26X0.c
  • Replace the following lines in CC1310_LAUNCHXL.c file of you example

    #include <ti/drivers/uart/UARTCC26XX.h>

    and

    const UART_Config UART_config[CC1310_LAUNCHXL_UARTCOUNT] = {
        {
            .fxnTablePtr = &UARTCC26XX_fxnTable,

    with

    #include <ti/drivers/uart/UARTCC26X0.h>

    and

    const UART_Config UART_config[CC1310_LAUNCHXL_UARTCOUNT] = {
        {
            .fxnTablePtr = &UARTCC26X0_fxnTable,

    Thanks,

    Sai

  • I will implement this in my software and will get back to you...hopefully this will resolve my problem..
    Thank you so much for your kind help
    Best regards
    Ali
  • Hi sai!

    so the pseudo code for finding out the number of bytes in the fifo before issuing a uart read would be something like this :

    UARTCC26X0_control(uart,UART_CMD_GETRXCOUNT,argument??..what do I insert here)??

    how will the above function return the number of bytes sitting in the fifo?

    please guide

    best regards

    Ali

  • Hi sai!
    So here it goes...my long journey of finding the solution to this problem is over now finally...i have achieved what i wanted to achieve...here is how it went down finally:
    I upgraded to the latest sdk 3.10.i was previously running a very old version which didnot have support for UART26X0.c drivers.
    I changed my uart function table as told by yourself but it wasn't enough i had to also make some changes to the UART hardware attributes object in the launchxl.c file...remove the power management id change some macros to X0 instead of XX and the UART26X0.c was ready to use as the program built without errors.
    Then i used the following method to peek bytes in the uart fifo ring buffer and then read any number of bytes i want from that ring buffer.
    UART_control(uart,UART_CMD_GETRXCOUNT,temp);
    temp variable returns the number of bytes available in the fifo at this point.
    then i used a uart read for exact number of bytes as temp variable as follows:
    UART_read(uart,uart_buffer,temp);
    I was able to read the exact number of bytes as available in the fifo,something that really takes the burden off from the processor of reading uart data byte by byte.
    My application is to find the number of number received over uart in 10ms and process them over radio without causing a race condition while new bytes arrive and the old ones are still processed.
    Thank you so much for your support and guidance..
    Looking forward for more success and learning in future
    Ali