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

How to know nRF52832 UART tx memory?

Hi, I'm using external board with nRF52832. (SDK 15.0.0)

In my external board, there are no RTS,CTS pin. So I don't use hardware flow control (HWFC).

The problem is, I have to flush tx memory when memory is full but I don't know how to check it.

I rarely use tx memory that flushing every sec or minute seems to waste of power.

How can I know that tx memory is full?

Parents
  • Could you provide some code of the program, in order to get a better understanding of your situation?

  • static void nus_data_handler(ble_nus_evt_t * p_evt)
    {
    		
        if (p_evt->type == BLE_NUS_EVT_RX_DATA)
        {
            NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
            NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
    				
    						if(p_evt->params.rx_data.p_data[0]== '0')
    						{
    								nrf_gpio_pin_write(13,0);//turn off motor
    						}
    						else if(p_evt->params.rx_data.p_data[0]== '1')
    						{
    								if(nrf_gpio_pin_read(8))
    								{
    									nrf_gpio_pin_write(13,1); //Turn on motor
    									pin8=true;
    								}
    								else if(nrf_gpio_pin_read(15))
    								{		
    									nrf_gpio_pin_write(13,1); //Turn on motor
    									pin15=true;
    								}
    						}
    					
        }
        
    }

    This above code is modified code from UART example.

    I control motor through uart tx data ( 0: turn off , 1: turn on ) and now I want to add some more code.

    When I add more code that use tx data, it cause error. ( Suddenly disconnect BLE )

    So I think I have to flush tx fifo memory.

    Am I missunderstanding??

    Thanks for repling.

Reply
  • static void nus_data_handler(ble_nus_evt_t * p_evt)
    {
    		
        if (p_evt->type == BLE_NUS_EVT_RX_DATA)
        {
            NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
            NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
    				
    						if(p_evt->params.rx_data.p_data[0]== '0')
    						{
    								nrf_gpio_pin_write(13,0);//turn off motor
    						}
    						else if(p_evt->params.rx_data.p_data[0]== '1')
    						{
    								if(nrf_gpio_pin_read(8))
    								{
    									nrf_gpio_pin_write(13,1); //Turn on motor
    									pin8=true;
    								}
    								else if(nrf_gpio_pin_read(15))
    								{		
    									nrf_gpio_pin_write(13,1); //Turn on motor
    									pin15=true;
    								}
    						}
    					
        }
        
    }

    This above code is modified code from UART example.

    I control motor through uart tx data ( 0: turn off , 1: turn on ) and now I want to add some more code.

    When I add more code that use tx data, it cause error. ( Suddenly disconnect BLE )

    So I think I have to flush tx fifo memory.

    Am I missunderstanding??

    Thanks for repling.

Children
No Data
Related