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

the uart examle doesn't work for all pins, for most pins i tried actually.

Hi.

I have nrf52840-dk board.
i tried the UART example from the peripherals directory. it works with the default, if i open a console on /dev/ttyACM0 and on /dev/ttyUSB0 i can see the "start" message and pressing a key echos it back. 
/dev/ttyUSB0 is a usb TTL i have that is connected to my laptop and to (at first) p0.06, p08.

problem started when i tried to change the pins to p0.9 and p0.10. i didn't change anything else, just the pins numbers.

BTW i tried the armgcc (make) and ses.

i see nothing not on ACM0 nor on USB0.

without debugging only running JLinkExe and halt i can see IPSR is 012, which is debug reserved flag, i guess it means the processor reached the error handler.

trying to debug indeed i reach the error handler from within the event handler of the uart, removing the calls to `APP_ERROR_HANDLER` allows the program to run but still not output on the USB0 port.

i tried ports i saw in other example i think it was p0.27' it wokred, but port 17,19,20,21 did not.

I don't get it, either you CAN use all ports that are not used to something else (i tried 00 and 01 but i understand they connect to the crystal...) or you can't how can it be that ii'm currently able to use only 4 pins ????
is there  a list of pins i can use ? and is that list relevant only for ntf52840-dk or to any device using nrf52840 chips ?
Do these pins also work for uarte ?


Parents
  • pin 9 and 10 are connected to NFC on the DK. If you need to use those pins as generic GPIO then you need to set CONFIG_NFCT_PINS_AS_GPIOS in your preprocessor defines.

    Please check the link here to understand more.

  • thanks you!
    that goes for 9 and 10, what about 21,20 ? 17, 19 ? which pins ARE free to use with the uart ?? it's hard to get a strait answer for that here in the forum.... in the PDK it doesn't state anything regarding 9,10. that's why i assumed they are free.
    where can i get a normal list of free pins ??

  • Please turn your DK around and there are markings for preallocated pins for few things. For UART you can see pins 05, 06, 07, 08  should be used.

  • you either misunderstand my question or contradicting other posts in the forum i'm affraid.
    Yes the official pins for rx\tx for uart0\uarte0 are 6 and 8, but it was stated that any other pin that does not have anothe usage (like xtel, nfc and the like) can be used. also the demo that uses both uart0 and uarte1 uses pins named ARDUINO_SCL and another ARDUINO_XXX pin meaning it is possibe.
    I was sure 9,10 were free, you explained that they were not, ok, even though it's NOT printed on the back of the DK board.
    So i'm asking which pins can be used for uarte0\1 without changing any configuration on the DK board, again there is an example that uses other pins, only those pins are free ? if so why is it stated that any other pin can be used ? several pins are marked on the back of the board as DIOs so if it uses as DIO can't i use it for the uart or do i need to setup something in the sdk_config to disable it as DIO as well ?

  • OK, I think we both were on different page in understanding the problem.

    1. Just having UART communication between two devices you can use any pins from the nRF52840 chip.
    2. On DK, for simplicity and to make your evaluation and prototyping easy, we have assigned few GPIO pins to certain features. Like few GPIOs are connected to buttons few of them to LEDS and few as you see on the back side of the DK. This settings are only for the DK and on your final product you can choose different pins.
    3. On nRF52840 DK, pin 09 and 10 are connected to NFC and as I mentioned you need to define the macro in your project and you can still use those pins for any other peripehral. In your case, after defining CONFIG_NFCT_PINS_AS_GPIOS , you can use pin 09 and 10 for uarte0.
    4. If you want to see your uarte0 data on PC, then the pins needs to be mapped into a COM port on your PC. And this can only happen with the CDC driver which is inside the Segger chip on the DK. The Segger chip listens to the pre allocated TX/RX/RTS/CTS pins on the DK and converts them into a COM port CDC data that your PC can listen in any terminal.
    5. The UART data is NOT automatically converted into /dev/ttyACM0 or /dev/ttyUSB0 mapping on your linux machine without the segger chip showing up as a COM device.
    6. on your final product, most likely you will not have the segger, debugger chip. That means all uarte0 data on your final product, you will not be able to see it directly on the PC terminal unless you connect to some COM adapter.

    I think the confusion that arises for you is that you think you can use any pins for uarte. Which is correct on your final product. To be able to automatically have COM port mapped on your PC, we assigned few UART pins that the SEGGER chip listens to and converts them to CDC UART data that your PC maps onto a COM port.

    I hope that this is a bit clearer.

  • Thanks for that :-) but that's not what i meant.
    I mean indedd 06 and 08 works just fine, however, when i'm using other pins i'm not using /dev/ttyACM0, i have a usb TTL (serial to usb) that is connected to my pc using usb and to the DK board on the other side. like i wrote in the original post.

    let's drop 9,10 , i know some ports are used for leds\xtel\buttons etc....
    as far as i know all of them were supposed to be printed on the back of the DK board, apparently they are not...
    So i'll rephrase.
    i want to communicate between my DK board and a usb to serial board connected to my PC.
    I want to use the uart example and maybe replace the printf with a function that outputs everything to the uarts. which pins beside 8 and 6 i can use without  changing configuration in sdk_config.

    hops it clarifies my question (it is device to device comm)

Reply
  • Thanks for that :-) but that's not what i meant.
    I mean indedd 06 and 08 works just fine, however, when i'm using other pins i'm not using /dev/ttyACM0, i have a usb TTL (serial to usb) that is connected to my pc using usb and to the DK board on the other side. like i wrote in the original post.

    let's drop 9,10 , i know some ports are used for leds\xtel\buttons etc....
    as far as i know all of them were supposed to be printed on the back of the DK board, apparently they are not...
    So i'll rephrase.
    i want to communicate between my DK board and a usb to serial board connected to my PC.
    I want to use the uart example and maybe replace the printf with a function that outputs everything to the uarts. which pins beside 8 and 6 i can use without  changing configuration in sdk_config.

    hops it clarifies my question (it is device to device comm)

Children
Related