3 Replies Latest reply on Jun 24, 2014 1:25 AM by eyan

    UART does not receive

    eyan

      When uart receives bytes, it does go entering to interrupt call back often.

       

      I should send uart packet several times (2 ~ 8), then uart can receive.

      Byte size is regardless.

       

      Can anybody have same experiences?

       

       

      int Uart_Init(BLE_PROFILE_PUART_CFG *puart_cfg, BLECM_FUNC_WITH_PARAM puart_rx_callback)

      {

      puart_selectUartPads(puart_cfg->rxpin, puart_cfg->txpin, 0x00, 0x00);


      // Initialize the peripheral uart driver

      puart_init();

       

       

      // Since we are not configuring CTS and RTS here, turn off

      // hardware flow control. If HW flow control is used, then

      // puart_flowOff should not be invoked.

      puart_flowOff();

       

       

      //BEGIN - puart interrupt

      // The following lines enable interrupt when one (or more) bytes

      // are received over the peripheral uart interface. This is optional.

      // In the absense of this, the app is expected to poll the peripheral

      // uart to pull out received bytes.

       

       

      // clear interrupt

      P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

       

       

      // set watermark to 1 byte - will interrupt on every byte received.

      P_UART_WATER_MARK_RX_LEVEL (1);

       

       

      // enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART

      // Interrupt Controller

      P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

      // Set callback function to app callback function.

      puart_rxCb = application_puart_interrupt_callback;

      // Enable the CPU level interrupt

      puart_enableInterrupt();

      /* END - puart interrupt */

       

      }

       

       

      void application_puart_interrupt_callback(void* unused)

      {

         // There can be at most 16 bytes in the HW FIFO.

         char readbytes[16];

         UINT8 number_of_bytes_read = 0;

       

         while(puart_rxFifoNotEmpty() && puart_read(&readbytes[number_of_bytes_read]))

         {

         readBuffer[number_of_bytes_read] = readbytes[number_of_bytes_read];

         number_of_bytes_read++;

         ble_trace1("uart rx data is %d", (UINT8*)readBuffer[number_of_bytes_read]);

         }

       

        P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

      P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

      }