This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A simple BLE-less UART example not working on nRF51822

I am trying to do a simple UART test with nRF51822 without BLE functionality. The code is a simplified version of the UART example in nRF51 SDK, and can be found here . It is really not much there: it sends the data from RX back to TX; if it gets a 'q' or 'Q', it just quits. I use an external serial monitor (Bus Pirate) to interact with it. However, two strange things happen:

  1. If I compile it without SoftDevice (and ROM address starts with 0x00000), I can see nothing from my serial monitor, no matter what I type in.

  2. If I compile it with SoftDevice 8.0.0 (although it doesn't use any BLE functions, and ROM address starts with 0x18000), I can repetitively see "Start:" and "Hit.", even I type in nothing in my serial monitor, and there is no 1000ms delay in the between. It is strange because a) "Start:" is not part of the while loop and should only be printed out once in the beginning; b) If "Hit." means the while loop is executed, there should be 1000 ms delay.

Can anyone advise what I am missing in such a simple UART program?

Parents
  • Hi Diode,

    1. If the same code starts with softdevice then it should work fine without it if you have set the IROM and IRAM addresses accordingly. With your example softdevice does nothing but jump correctly to you application. you can try to debug the code without softdevice to see if your main is being executed.

    2. May be your serial monitor is configured to have flow control and It is possible that you have typed something on serial emulator before starting your application which was in the emulator TX buffer waiting to be transmitted (as nothing on the other side is ready to receive). As soon as you flashed your board, your app received that char and moved out of waiting.

    also if you want to have 1000ms wait in between Start and Hit, you need to swap this lines

                            printf("Hit.\r\n");
                            nrf_delay_ms(1000);
    
  • Hi Aryan. It turns out the it was because of the serial monitor was using open-drain mode so that it could not pull the line high. After switching it to normal mode (can pull the line high), I can see the loopback testing work on my serial command. Another small question: after hitting "q" the program will enter a infinite loop state. However, it gets itself out in a second or so and print out "Start:" (meaning a reset). Is this behavior expected because of something else (e.g. watchdog)?

Reply
  • Hi Aryan. It turns out the it was because of the serial monitor was using open-drain mode so that it could not pull the line high. After switching it to normal mode (can pull the line high), I can see the loopback testing work on my serial command. Another small question: after hitting "q" the program will enter a infinite loop state. However, it gets itself out in a second or so and print out "Start:" (meaning a reset). Is this behavior expected because of something else (e.g. watchdog)?

Children
No Data
Related