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

Align UART transmission/reception with GPIO pin signaling low/high

How do I align UART transmission/reception with GPIO pin signaling low/high? I wanted to do this because BLE chip is receiving the Product ID & device name from microcontroller over uart & it is also sending the HID output reports over uart. The steps/logic I would like to implement -

(A) After receiving the Product ID & device name, pull GPIO pin low. (There is more logic included)

I tried this but the pin goes low, before all data is read. I was tracking the error code to return NRF_SUCCESS but that does not help. I was trying to do something like this for app_uart_put() & app_uart_get()

for(ind = 0; ind < BLE_INFO_FRAME_LEN; ind++)
	{
		//NRF_LOG_RAW_INFO("Byte: %d\n", ble_info_frame[ind]);
		while (app_uart_put(ble_info_frame[ind]) != NRF_SUCCESS);
	}
	if(ind == BLE_INFO_FRAME_LEN)
	{
		nrf_gpio_pin_clear(0);
	}

(B) After transmitting HID output report, pull GPIO pin high

Is there a flag or interrupt which tracks this?

Parents
  • Hi,

     

    I tried this but the pin goes low, before all data is read. I was tracking the error code to return NRF_SUCCESS but that does not help. I was trying to do something like this for app_uart_put() & app_uart_get()

    Try setting the signal inactive in the uart event handler, upon event "APP_UART_TX_EMPTY". This should align the pin with the UART transmission.

    (B) After transmitting HID output report, pull GPIO pin high

    If I understand your scenarios correctly (and please; correct me if I am mistaken), you want to set the pin again after transmitting a given data stream. This would then be equal to your first scenario.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    I tried this but the pin goes low, before all data is read. I was tracking the error code to return NRF_SUCCESS but that does not help. I was trying to do something like this for app_uart_put() & app_uart_get()

    Try setting the signal inactive in the uart event handler, upon event "APP_UART_TX_EMPTY". This should align the pin with the UART transmission.

    (B) After transmitting HID output report, pull GPIO pin high

    If I understand your scenarios correctly (and please; correct me if I am mistaken), you want to set the pin again after transmitting a given data stream. This would then be equal to your first scenario.

     

    Kind regards,

    Håkon

Children
Related