AnsweredAssumed Answered

K21 KDS KSDK UART HAL DRIVER and FIFO problem

Question asked by sudhanshu mehta on Nov 17, 2015
Latest reply on Nov 19, 2015 by sudhanshu mehta

Hi Team,

I have 2 questions

Question 1:

 

I have tower K21 board. I am using KDS. KSDK and MQX (not PE).

 

I am using HAL driver for UART2. (debug port is uart5 and it is separate and working).

 

I am able to transmit and receive data by polling on uart2.

 

can you help me in providing interrupt based reception example using HAL driver.

In the document http://2014ftf.ccidnet.com/pdf/0468.pdf It is written that its possible,

 

i can see some APIs like UART_HAL_SetIntMode(baseAddr,kUartIntRxDataRegFull , 1);

but how to use/get function which will be called when receive interrupt happens.

 

Question2:

 

how to define the receive queue size

 

please provide me some example.

 

following is my code having uart working with polling

uint8_t  ret1        = 0;

   

   uint8_t  rxChar      = 0;
    uint32_t byteCountBuff   = 0;
    uint32_t uartSourceClock = 0;
    UART_Type * baseAddr = UART2;

 

    const uint8_t buffStart[]= "\r\n++ UART 2+++\r\n";
    const uint8_t bufferData1[]  = "\r\nType\r\n";

 

   configure_uart_pins(2U);
   CLOCK_SYS_EnableUartClock(2);
   uartSourceClock = CLOCK_SYS_GetUartFreq(2);
   UART_HAL_Init(UART2);

 

//------------------------port parameter----------------------------------------------------------

   UART_HAL_SetBaudRate(baseAddr, uartSourceClock, BOARD_DEBUG_UART_BAUD);
   UART_HAL_SetBitCountPerChar(baseAddr, kUart8BitsPerChar);
   UART_HAL_SetParityMode(baseAddr, kUartParityDisabled);

   

//------------------------port parameter----------------------------------------------------------

 

   UART_HAL_EnableTransmitter(baseAddr);
   UART_HAL_EnableReceiver(baseAddr);

//-----------------------------------send data----------------------------------------------------

   // Inform to start polling example
   byteCountBuff = sizeof(buffStart);
   UART_HAL_SendDataPolling(baseAddr, buffStart, byteCountBuff);

 

   // Inform user of what to do
   byteCountBuff = sizeof(bufferData1);
   UART_HAL_SendDataPolling(baseAddr, bufferData1, byteCountBuff);

 

   printf("\n task 2 started\n");
   while(1)
   {

 

      ret1 = UART_HAL_GetStatusFlag(baseAddr, kUartRxDataRegFull);
      if( ret1)
      {
      UART_HAL_ReceiveDataPolling(baseAddr,&rxChar, 1);
      UART_HAL_SendDataPolling(baseAddr, &rxChar, 1);

 

      }

 

      _time_delay_ticks(30);
      UART_HAL_SendDataPolling(baseAddr, buffStart, sizeof(buffStart));
   }

 

 

 

thanks

Sudhanshu

Outcomes