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

how to write simple uart program for sending and receiving data

hello there,

i am using nrf51422 but dont know how to write a program for uart. i want to send AT commands to Quectel M95 using uart . good help appriciated!!

cheers, Abhijeet

Parents Reply Children
  • thanks for your reply!!! yes man i have successfully complied and run that program but the program is transmitting and receiving the same thing ..actually i want to interface quectel ec25 withnrf51422 and want to send AT commands for gsm communication between nrf51422 and ec25 modem...but this program is just sending and receiving the same thing i want some reply from that board through ec25 through uart tell what the changes i have to do in this code that you have mentioned earlier.i just want to send something and receive some response ...how to do that using this code? thanks for your help!! your help appreciated!!

    cheers, Abhijeet

  • Are you using a nRF51-DK ? You could also take a look at the ble_app_uart example. In this example you can send and receive commands with the UART controlled by a BLE device. First configure the uart_init() function with the baud_rate and settings you want to use. Everything that the nRF51 receive over UART will be handled in the function uart_event_handle, and sent over BLE to a BLE central, e.g. your phone. Remember to flash the S130 SoftDevice to the nRF51.

    Try to use the nRF-Toolbox app, and the UART app inside the toolbox. Everything you receive over UART will be sent over BLE to your phone. You can also send commands with your phone, that will later be sent over UART to the ec25, in the nus_data_handler() function.

    You can then later modify the uart_event_handle() function, so that you send AT commands to the ec25 automatically, based on what the ec25 is sending to the nRF51.

  • hi, Yes i am using nrf51- DK (PCA10028) we tried doing as you suggested but when we connect the TX and RX pins of ec25 the ble is not getting iniated if i change the baudrate to 115200 as my ec25 communicates on that baudrate and also i am getting "start" printed continuosly on termite.

    Thanks in advance Abhijeet

  • The continuously printing of "start", means that the device is restarting. A reset indicates that you are running into the error handler, where the default behavior is to do a reset. You should then debug in order to find the reason for the reset. See this post about debugging.

  • hi, thank for your help but you did not understood my point maybe. I did not send anything on uart i just connected the TX and RX pin of ec25 to nrf51 board and flashed my program(i had set the baudrate to 115200 as per ec25 requirement) after successfully programming my nrf51 board i opened my termite as soon as i opened it was continuously sending "start[00]". And when i removed the TX and RX pin and changed the baudrate to 38400 and restarted the termit then my ble to uart communication was working fine. I want to know how can i make it to communicate with ec25 on baudate 115200.

Related