[SOLVED] UART Serial on nRF51822 dongle

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] UART Serial on nRF51822 dongle

    Has anyone used the UART serial port on this dongle on a Mac? Is the output supposed to show up in GDB or in the JLinkExe? Do I need a driver?
    The instructions for the dongle have me disable some of the USB CDC drivers (without this, I cannot connect to the chip).

    How do I see serial console output?

    I'm using the following code:

    Source Code

    1. // P0.21-3 are red, green, blue LEDs on development dongle
    2. GPIO_DIRSET = 7 << 21; // set pins to output
    3. GPIO_OUTSET = 7 << 21; // set pins high -- LED off
    4. GPIO_OUTCLR = 1 << 21; // set red led on.
    5. UART_ENABLE = 1;
    6. // GPIO UART
    7. // P0.08 RTS
    8. // P0.09 TXD
    9. // P0.10 CTS
    10. // P0.11 RXD
    11. UART_PSELRTS = 1 << 8;
    12. UART_PSELTXD = 1 << 9;
    13. UART_PSELCTS = 1 << 10;
    14. UART_PSELRXD = 1 << 11;
    15. UART_CONFIG = UART_CONFIG_HWFC_ENABLED;
    16. UART_STARTTX = 1;
    17. char* hello = "Hello, world.\n";
    18. uint8_t len = strlen(hello);
    19. for(int i = 0; i < len; ++i) {
    20. UART_TXD = hello[i];
    21. while(!UART_TXDRDY) /* wait */; // HANGS here
    22. UART_TXDRDY = 0;
    23. }
    24. GPIO_OUTSET = 1 << 21; // set pin low - red LED off.
    25. GPIO_OUTCLR = 1 << 22; // set pin low - green LED on.
    26. while(1);
    Display All
  • FYI some of the above code is wrong. I have updated code here, basically:

    Source Code

    1. GPIO_DIRSET = 3<<8;
    2. UART_ENABLE = 0b100;
    3. // Configure UART pins: GPIO UART
    4. UART_PSELRTS = 8; // P0.08 RTS
    5. UART_PSELTXD = 9; // P0.09 TXD
    6. UART_PSELCTS = 10; // P0.10 CTS
    7. UART_PSELRXD = 11; // P0.11 RXD
    8. UART_CONFIG = UART_CONFIG_HWFC_ENABLED; // enable hardware flow control.
    9. UART_BAUDRATE = 38400;
    10. UART_STARTTX = 1;
    11. unsigned char* hello = "Hello, world.\n";
    12. uint8_t len = strlen(hello);
    13. for(int i = 0; i < len; ++i) {
    14. UART_TXD = (uint8_t)hello[i];
    15. while(!UART_TXDRDY) /* wait */;
    16. UART_TXDRDY = 0;
    17. }
    Display All


    Full code includes some delays and other setup, see here. However, I still can't see console output when I do:

    Source Code

    1. ./disable_cdc.sh
    2. [plug dongle]
    3. make main_blink.bin upload
    4. [unplug dongle]
    5. ./enable_cdc.sh
    6. [plug dongle]
    7. screen /dev/tty.usbmodem1d111 38400


    Sometimes I'll get a few odd characters (eg ? in diamond) but I never see real output.

    It also really really sucks to have to plug and unplug dongle and disable and enable MacOS CDC drivers; if I don't unplug dongle I get pretty consistent kernel panics (!) when running the disable script.

    Any suggestions?

    Thanks a bunch,

    -c

    The post was edited 1 time, last by cmason ().

  • Hi,

    Is the output supposed to show up in GDB or in the JLinkExe?

    No. The idea behind CDC is that the J-Link also shows up as a virtual COM port so a terminal application (TeraTerm, Putty, etc.) can connect to the virtual COM port.

    The instructions for the dongle have me disable some of the USB CDC drivers (without this, I cannot connect to the chip).

    Yes, this is a limitation in the Mac OS X (!!) USB CDC kernel driver. It requests exclusive access to the device, so libusb is no longer able to get access to the J-Link, so debugging is not possible.
    This is why the USB CDC drivers of Mac need to be temporarily disabled.
    Under Linux, this is not necessary.
    So on Mac, currently the CDC functionality can not be used in parallel to the debug functionality of the J-Link OB.


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi guys,

    thanks cmason for the information and your scripts, and sry for posting on such an old post.

    Just one question @Alex. You said, thats currently (2013) its not possible to work with the CBC functionality. But, do you think thats possible in near future, or is it better to find another way to debug on OSX systems? :)

    Thanks in advance,
    kind regards
  • Hi,

    We are currently taking a look at the OS X implementation again, in order to check if there is a simple change possible to avoid needing to disable the CDC drivers of OS X.
    I expect some results regarding this later today (actually a colleague of mine is looking at this).


    - Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • O.K., think we found it.
    Will be changed in one of the next versions (planned to be available within the next 3-4 weeks, maybe earlier),
    so it will no longer be required to disable the Mac OS X CDC drivers, to use the J-Link functionality.


    - Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Sorry for the delay. Busy days...
    V4.88 has been released.
    It comes with the fix for J-Links with VCOM support, mentioned earlier.
    Download-Link: segger.com/jlink-software.html

    - Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi,

    Thanks for the feedback, so I will close this threads for now.


    - Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.