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

Send serial commands over GPIO on nRF52832

Hello, I'm having a trouble over here, I read some tutorials for creating custom services and characteristics for BLE, and everything is running fine, I have a service with a characteristic that hold some text in hex (uint8_t), and I set the permissions to read/write that characteristic, now, i want to send a serial command over one of the GPIO ports, and I'm using the nRF52 DK so I'm using the P0.06 (TXD) and P0.08 (RXD), but I don't have a clue how to send the serial command to those GPIO ports, I need to send a command for a nextion TFT screen, to change a value, so I need to send a text first like (t0.val="test") and then 0xFF three times so the screen will read the commands.

How do I do that on the nRF52832?, I saw a UART example on the SDK but I cannot understand it very well, I don't want to establish a deep connection, just send some commands, and I might also point that I'm a beginner on C programming.

Parents
  • a nextion TFT screen

    One of these: https://nextion.itead.cc/ ?

    That page says:

    "NEXTION display quickly connects to MCU via 5V TTL Serial"

    Note that nRF52832 pins are not 5V tolerant.

    I need to send ... 0xFF three times so the screen will read the commands.

    Are you sure? The page also says:

    "utilizes simple ASCII text based instructions"

    0xFF would not normally be considered "ASCII text".

  • Have you checked the lines with a logic analyzer, to see if the expected strings are sent to the screen? Do the screen send any response back to the nRF? Do you get any events from the UART peripheral?

  • No, I do not have a logic analyzer, however I used the pin number 6 and 8 of the nRF52 DK to test the UART example with my own computer, and I can read exactly what I need to send to the screen, that's why I think the string are sent correctly, and I don't know how to get events from the UART peripheral, please If you have any other clue let me know, I will keep trying

  • Did you use the same pins, or different ones? Events will depend on which UART implementation you are using. If you use the UART peripheral example in the SDK, uart_error_handle() will be called when events are received. Use your debugger to set a breakpoint in this function and see if it is being called.

  • Just to let anyone know, I solved the problem and it wasn't related to the nRF52 i was using the ASCII commands \r and \n for return and new line on sending the commands to the nextion and that make the screen not able to receive any further command, all I needed was to send the command clean, without anything else

  • Thanks for the feedback.

    A good tip when working with any device like this is to always start by connecting it to a PC with a terminal program, and use that to manually send commands to it, and observe the results and the responses.

    That way you can work out the correct commands & responses without the added complication of embedded hardware & software development.

    Especially useful when you're not too familiar with the embedded target.

Reply
  • Thanks for the feedback.

    A good tip when working with any device like this is to always start by connecting it to a PC with a terminal program, and use that to manually send commands to it, and observe the results and the responses.

    That way you can work out the correct commands & responses without the added complication of embedded hardware & software development.

    Especially useful when you're not too familiar with the embedded target.

Children
No Data