• AVR Freaks

Hot!PIC32MM0256 UART2 pin share for Rx and Tx

Author
Reini
Junior Member
  • Total Posts : 66
  • Reward points : 0
  • Joined: 2015/09/11 03:21:24
  • Location: 0
  • Status: offline
2020/11/30 06:05:03 (permalink)
0

PIC32MM0256 UART2 pin share for Rx and Tx

Hey all :-)
I'm currently working with a PIC32MM controller and use one pin for transmitting as well as receiving asynchrone serial data (@300 baud). I did the same with PIC18 micro's but now I am unsure if that can be done with a PIC32MM controller.
The datasheet does not say I can share the same pin for transmitting and receiving serial data (with UART2 for example).
Does anyone tried this?
I would like to use RB5 as a TX output, but with the option to readback what I sent (RX):
    RPOR2bits.RP11R = 4;   // U2TX SPDIFData out
    RPINR9bits.U2RXR = 11; // U2RX SPDIFData in
With kind regards,
Reini
post edited by Reini - 2020/11/30 06:08:34
#1

4 Replies Related Threads

    Reini
    Junior Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2015/09/11 03:21:24
    • Location: 0
    • Status: offline
    Re: PIC32MM0256 UART2 pin share for Rx and Tx 2020/11/30 06:20:23 (permalink)
    4 (1)
    Well, I think I wrote to soon :-) There is a loopback option (UxMODEbits.LPBACK) which disconnects the Rx pin from the receiver, but let's the Tx pin do its job. With that option it should be possible to readback what I've sent. If it works, I will update this post soon :-)
    #2
    Reini
    Junior Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2015/09/11 03:21:24
    • Location: 0
    • Status: offline
    Re: PIC32MM0256 UART2 pin share for Rx and Tx 2020/11/30 06:54:14 (permalink)
    0
    Yep, that's working perfectly! Using LPBACK in UxMODE you can transmit UART data out with one pin and at the same time reading back that data. I still rather would use the pin as Rx reference (for example if the pin was kept low by a short), but this is usable also.
     
    So solved :-)
     
    Reini
    #3
    Reini
    Junior Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2015/09/11 03:21:24
    • Location: 0
    • Status: offline
    Re: PIC32MM0256 UART2 pin share for Rx and Tx 2020/11/30 07:02:41 (permalink)
    5 (1)
    For the record:
    It seems to work also without the LPBACK option, by using PPS and connecting Tx and Rx of UART2 to the same pin as I stated in the original post. I thought it didn't work, but my receiving interrupt was not configured correctly...
    So both options work, using the same pin as well as using LPBACK. Of course, I will be using the same pin, because then I now for sure what I sent :-)
    Thanks for reading!
     
    With kind regards,
    Reini
     
    #4
    toms
    Senior Member
    • Total Posts : 121
    • Reward points : 0
    • Joined: 2006/03/07 18:06:24
    • Location: London, UK
    • Status: offline
    Re: PIC32MM0256 UART2 pin share for Rx and Tx 2020/12/08 07:18:02 (permalink)
    4 (1)
    Are you wanting to monitor what is sent physically, i.e. to detect collisions between multiple transmitters?
     
    Or do you simply want to verify what you sent? If that is the case, I would really like to know why confidence in the UART/transmitter is so low. :-)
     
    #5
    Jump to:
    © 2021 APG vNext Commercial Version 4.5