Menu

Using TX pin as GPIO

Help
Peter
2017-12-06
2017-12-06
  • Peter

    Peter - 2017-12-06

    I have a PIC16F18346 with PORTA.2 connected to a 433 MHz radio transmitter which turns on various things by toggling the pin on and off (bit banging). This works fine.

    I need to send strings to other devices using the radio transmitter. If I use PPS to map the EUSART TX pin to PORTA.2, and do the usual serial setup (baud rate etc.) at the start of my code this works fine.

    However if I try to do both of these, only the text string is sent - the bit banging stops working. Commenting out the serial code makes it work again. It is like the EUSART hogs the PORTA.2 pin once it is set up so it cannot be used, which makes sense because it needs to hold the pin high/low for idle.

    I need to be able to do both the serial and the bit banging with the same pin. Any ideas how I can do this?

    I am going to try redoing the PPS setup when switching between serial/bit banging mode (temporarily set RA2PPS = 0x0000, then revert back to RA2PPS = 0x14). Does that sound like something that will solve the problem?

     
    • Anobium

      Anobium - 2017-12-06

      Use the software serial will resolve as your comment re EUSART is correct- the newer software serial uses very little program memory.

       
  • William Roth

    William Roth - 2017-12-06

    You should be able to do both with the same pin.

    Prior to ussing the pin as general IO use PPS to set the Pin as General I/O. Prior to using the Pin for serout use PPS to set the PIN as TX. Make sure PPS1WAY is setup correctly in #config.

     

Log in to post a comment.