Trying to read data from uart

hi to all,
I am trying to send data from one of controller to rsl10 through uart .
but rsl10 is not able to read the data at fist attempt , its reading when controller is sending same message more 50 times . Is i’m doing wrong ?

@nandadhage
Is your code based on one of our examples?
Can you attach your project files so we can test and reproduce the issue on our side?

peripheral_server_uart.zip (717.9 KB)

PLEASE CHECK THIS PROJECT I AM SENDING SOME DATA FROM DOCKLIGHT(TERMINAL) and trying to read data and according to that only I am advertising or connecting
.

Looking through the code, it looks like there are several modifications to the ble_std.c and other library routines. These changes are what’s preventing the device from advertising and connecting properly.

For example the customer has modified several routines in ble_std.c including GAPM_ProfileAddedInd(), GAPC_ConnectionReqInd(), etc.

From the looks of the changes it seems you’re attempting to start advertising only after receiving data on the UART interface. The sample you’re starting from works the other way around - the UART port is only actively monitored when there is a ble connection. This saves power since there’s no point in monitoring the UART if there’s nowhere to send the data.

If you could explain briefly what you’re trying to do differently than what is provided by the peripheral_server_uart example it may in giving more guidance on how to modify the example to fit your needs.

hello jamie.meacham,

Thanks for your reply.

You Understood correctly that I am trying to do.

Overall moto is All control of rsl10 handle by the Renesas controller. Means Renesas controller will send command to rsl10 , according to command rsl10 will act. example Renesas will send command to rsl10 for start advertising , then rsl10 will start advertise and give acknowledge.

please help me in this regards.

If you simply want the RSL10 to be “ON” or “OFF” the air, you could use a GPIO from an external controller to indicate the desired state. But it sounds like you’re trying to control more than just that via UART command interface.

I think you’re trying to do something like this;

  1. Implement a UART interface to control / query the RSL10 state
  2. based on the state controlled via the UART, enable/disable the RSL10 BLE communication, monitor and control what is communicated.

That would look something like this:

Start with an example such as peripheral_server.

Add a uart.c file and define a UART_init() function that you call from the app_init().

You’ll likely want to define the UART to be interrupt based on reception of a byte and either DMA or interrupt based to transmit back to the external controller.

Now define a UART Interrupt Service Routine to process received bytes. Based on the received messages, respond by queueing the response, and change a state or data variable as appropriate based on the received message. In addition, if the command is to enable the BLE interface you should take the steps in App_Initialize to enable the RF power and call BLE_Initialize(). If the command is to disable the BLE interface you would power-down the RF interface.

The main point here is that unlike the peripheral_server_uart interface which uses the UART only when there’s an active connection, you’re configuring the UART to always be enabled and always processing the messages, and enabling/disabling the RSL10’s RF interface based on those messages.

  1. define a UART Interrupt Service Routine to process received bytes →
    need to write ISR code or its available.?
    I unable to find UART ISR code in peripheral_server_uart example .

one more if I want to UART always be Enable in peripheral_server_uart what should I do?

There isn’t an example with an interrupt based UART implementation. I’ve made one and attached it along with a skeleton of a main app.c that shows something like I think you’re trying to do.

The Uart.c/.h uses interrupts to process the receive/transmit data. When an end-of-line or carriage-return is received over the UART it sets a flag indicating data is available. The main loop spins waiting for events. It then polls the UART interface to see if a complete message has been received and if so it retrieves it and processes it.
uart.c (11.8 KB)
uart.h (4.2 KB)
app.c (2.9 KB)

thanks for your solution , its working but again I want data in uart when I will send some data from mobile.

I tested it through the pc terminal data is sending and receiving properly , but when i am sending data through mobile its not receiving . And transmitting (from rsl10) data also not getting on mobile.?

here I am attaching my project .peripheral_server.zip (714.4 KB)

The example code I posted just had stubs for enabling the BLE interface and was an example of how you might want to proceed. You’ll need to implement the code for managing the BLE interface and services that you want to provide.

1 Like

how I do interface UART with Interrupt based ?
I used Sys_UART_DIOConfig(APP_DIO_CFG, 5, 4); this function but its not working , what i need to do ?

The SysUART_DIOConfig() function sets which I/Os are used for the UART interface and their drive strength.

The interrupts are enabled by the code following the comment “Enable UART Interrupts” below found in UART_Initialize().

	/* Configure TX and RX pin with correct current values */
	Sys_UART_DIOConfig(DIO_6X_DRIVE | DIO_WEAK_PULL_UP | DIO_LPF_ENABLE,
					   CFG_DIO_TXD_UART, CFG_DIO_RXD_UART);

	/* Enable device UART port */
	Sys_UART_Enable(CFG_SYS_CLK, CFG_UART_BAUD_RATE, UART_DMA_MODE_DISABLE);

	/* Enable UART Interrupts */
	NVIC_EnableIRQ(UART_RX_IRQn);
	NVIC_EnableIRQ(UART_TX_IRQn);

The code you sent seems to be configuring the UART interface and enabling the interrupts. However, the call to Sys_UART_DIOConfig() in your question doesn’t match the call in the code. Please check that you’re using the UART_Initialize routine, and that you have configured the Tx and Rx pins correctly for how you’re connecting them in your system.