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.

CCS/CC3220MODA: UART Receive on Interrupt bases

Part Number: CC3220MODA
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

Hi,

I am using CC3220MODA customized board. Trying UART receive on interrupt bases.

I am able to receive the data upto 32 bytes. Later on I am not able to receive any data.

Below is the attached code.

Can anyone help me out to crack the issue.

Thanks,

  • HI ,

    Kindly use my code you will be able to get data properly.here is my code below

    #include "rom.h"
    #include "rom_map.h"
    #include "hw_memmap.h"
    #include "hw_common_reg.h"
    #include "hw_types.h"
    #include "hw_ints.h"
    #include "uart.h"
    #include "interrupt.h"
    #include "pinmux.h"
    #include "utils.h"
    #include "prcm.h"
    #include <string.h>
    // Common interface include
    #include "uart_if.h"

    //*****************************************************************************
    // MACROS
    //*****************************************************************************
    #define APPLICATION_VERSION "1.1.1"
    #define APP_NAME "UART Echo"
    #define CONSOLE UARTA0_BASE
    #define UartGetChar() MAP_UARTCharGet(CONSOLE)
    #define UartPutChar(c) MAP_UARTCharPut(CONSOLE,c)
    #define SECONDUART UARTA1_BASE
    #define Uart1GetChar() MAP_UARTCharGet(SECONDUART)
    #define Uart1PutChar(c) MAP_UARTCharPut(SECONDUART,c)
    #define MAX_STRING_LENGTH 80

    //*****************************************************************************
    // GLOBAL VARIABLES -- Start
    //*****************************************************************************
    volatile int g_iCounter = 0;

    #if defined(ccs)
    extern void (* const g_pfnVectors[])(void);
    #endif
    #if defined(ewarm)
    extern uVectorEntry __vector_table;
    #endif
    char cString[MAX_STRING_LENGTH+1];
    char cString1[MAX_STRING_LENGTH+1];
    char cString2[MAX_STRING_LENGTH+1];
    char cCharacter;
    int iStringLength = 0;
    unsigned char uartRxBuff[128];
    unsigned int uartRxLength = 0;
    //*****************************************************************************
    // GLOBAL VARIABLES -- End
    //*****************************************************************************

    static void
    DisplayBanner(char * AppName)
    {
    Report("\n\n\n\r");
    Report("\t\t *************************************************\n\r");
    Report("\t\t CC3200 %s Application \n\r", AppName);
    Report("\t\t *************************************************\n\r");
    Report("\n\n\n\r");
    }

    //*****************************************************************************
    //
    //! Board Initialization & Configuration
    //!
    //! \param None
    //!
    //! \return None
    //
    //*****************************************************************************
    static void
    BoardInit(void)
    {
    /* In case of TI-RTOS vector table is initialize by OS itself */
    #ifndef USE_TIRTOS
    //
    // Set vector table base
    //
    #if defined(ccs)
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    #endif
    #if defined(ewarm)
    MAP_IntVTableBaseSet((unsigned long)&__vector_table);
    #endif
    #endif
    //
    // Enable Processor
    //
    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();
    }
    ///////////////////////////////////////////////////////////////////////////////
    // Now i'm gonna do changes from here

    void Uart1IntHandler(void)
    {
    unsigned long intStatus = MAP_UARTIntStatus(UARTA0_BASE, true);
    if((intStatus & UART_INT_RX) && MAP_UARTCharsAvail(UARTA0_BASE))
    {
    uartRxLength++;
    uartRxBuff[uartRxLength] = (unsigned char)MAP_UARTCharGetNonBlocking(UARTA0_BASE);
    MAP_UARTCharPut(UARTA0_BASE,uartRxBuff[uartRxLength]);
    }
    else if(intStatus & UART_INT_RT)
    {
    uartRxBuff[0] = uartRxLength;
    uartRxLength = 0;
    }
    MAP_UARTIntClear(UARTA0_BASE, intStatus);
    }
    //*****************************************************************************
    //!
    //! Main function handling the uart echo. It takes the input string from the
    //! terminal while displaying each character of string. whenever enter command
    //! is received it will echo the string(display). if the input the maximum input
    //! can be of 80 characters, after that the characters will be treated as a part
    //! of next string.
    //!
    //! \param None
    //!
    //! \return None
    //!
    //*****************************************************************************
    void main()
    {
    char cString[MAX_STRING_LENGTH+1];
    char cCharacter;
    int iStringLength = 0;
    //
    // Initailizing the board
    //
    BoardInit();
    //
    // Muxing for Enabling UART_TX and UART_RX.
    //
    PinMuxConfig();
    //
    // Initialising the Terminal.
    //
    InitTerm();
    MAP_UARTFlowControlSet(UARTA0_BASE, UART_FLOWCONTROL_NONE);
    MAP_UARTFIFODisable(UARTA0_BASE);
    MAP_UARTIntRegister(UARTA0_BASE, Uart1IntHandler);
    //MAP_UARTIntEnable(UARTA0_BASE, UART_INT_RX);
    MAP_UARTIntEnable(UARTA0_BASE, UART_INT_RX|UART_INT_RT);/*
    // Initialize the second UART interface
    MAP_UARTConfigSetExpClk(SECONDUART,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH),
    UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));*/
    //
    // Clearing the Terminal.
    //
    ClearTerm();
    DisplayBanner(APP_NAME);
    Message("\t\t****************************************************\n\r");
    Message("\t\t\t CC3200 UART Echo Usage \n\r");
    Message("\t\t Type in a string of alphanumeric characters and \n\r");
    Message("\t\t pressenter, the string will be echoed. \n\r") ;
    Message("\t\t Note: if string length reaches 80 character it will \n\r");
    Message("\t\t echo the string without waiting for enter command \n\r");
    Message("\t\t ****************************************************\n\r");
    Message("\n\n\n\r");

    while(1)
    {
    /*Report("Enter the string:\r\n");
    uart0_rx();
    Report("\n\rEntered String is:%s\n\r", cString);
    Report("\n\rEnter the String for Uart1:\r\n");
    uart1_rx();
    Report("\n\rEntered String is:%s\n\r", cString1);
    Report("\n\rCheck Other Terminal:\r\n");
    if(strcmp(cString,"hi")==0)
    Report("\n\rHello\n\r");*/
    }
    }

    Regards Manish

  • Hi Manish,

    Thanks for your valuable reply.
    I just wanted to know what is wrong in my code. Am I missing something in my code.

    Thanks,
    Regards Suchitha
  • Hi Manish,

    Please reply.

    Thanks
  • Hi Suchitha,
    Sorry for the late reply I'm little busy while doing some task which has been allocated to me in my organization. So give me some time I'll compile your code and check what is the exact problem. Meanwhile, you can refer to my code for better understandings. As soon as my task is over I'll try to reply.


    Thanks
    Manish Thakur
  • Hi Suchitha, 

    I don't know without UART_read call how callback function is triggered.

    Whenever UART_read buffer is full that time only callback function will trigger.

    I attached your modified code :

    #define RECV_SIZE 32 // modify as per your requirement 
    
    sem_t signal_to_write;
    
    void uart_isr_callback (UART_Handle handle, void *buf, size_t count)
    { 
         sem_post(&signal_to_write); 
    }
    
    void *Uart_thread(void *pvParameters)
    {
      uint8_t recv_data[RECV_SIZE]; // as per your receive data size
      UART_Handle uart;
      uint8_t buf[200] = "Your Write Data";
      int32_t count = 15;
      
      sem_init(&signal_to_write,0 ,0);
      
      UART_Params uartParams;
      
          /* Create UART process */
      UART_Params_init(&uartParams);
      uartParams.writeDataMode = UART_DATA_BINARY;
      uartParams.readDataMode = UART_DATA_BINARY;
      uartParams.writeMode = UART_MODE_BLOCKING;
      uartParams.readMode = UART_MODE_CALLBACK;
      uartParams.readReturnMode = UART_RETURN_FULL;
      uartParams.readEcho = UART_ECHO_OFF;
      uartParams.baudRate = 115200;
      uartParams.readCallback = &uart_isr_callback;
    	
      uart = UART_open(Board_UART0, &uartParams);
      if (uart == NULL)
      {
         /* UART_open failed */
          while(1);
      }
    	
      while(1)
      { 
    	UART_read(uart, recv_data, RECV_SIZE); // after read buffer is full callback function trigger
    	sem_wait(&signal_to_write);
    	UART_write(uart, buf, count);
      }
    }

    Vasu

  • Hi Manish,

    Were you able to compile my code and check what is the exact problem. Waiting for the reply.

    Please do the needful as soon as possible.

    Thanks,

    Regards,

    Suchitha

  • Hi Suchitha,
    I'm working on your code only but I also did not get. Still working if in between any TI employee can solve it would be great. For getting it proper understanding it'll take time to me as I have nearly one month of experience in CC3220. So please , give me some time.


    Thanks
    Manish Thakur
  • Hi Suchitha

    Till now I can suggest after receiving 32 bytes try to clear your buffer and then check it again
  • Hi Vasu,

    Thanks for your reply.

    You had created pthread called Uart_thread, which will be scheduled frequently. Every time the Uart_thread is scheduled you are re-initializing the uartParams. I think re-initializing the uartParams is not necessary.

    So can you check what is the exact problem in my code.

    Thanks
    Regards,
    Suchitha
  • Hi Suchitha,

    Please refer to this related thread: e2e.ti.com/.../2872919

    Thanks,
    Alexis