0
\$\begingroup\$

Arduino appears to be able to use software serial on any pins you choose. I am trying to test the same scenario on an atMega128 however, all of the examples and notes I find require using the RX pin on External Interrupt 0 which is PIND0. I have successfully implemented TX on any pin I choose. My question is very specific. Can a RX pin for software serial be implemented on any GPIO pin I choose? If so, is there an example of how to test this. I Have not been able to get the RX working in my environment. Thanks

\$\endgroup\$
1
\$\begingroup\$

AVR305 explains how to implement a software UART on any two pins. Note that not using an interrupt means that the CPU busy-waits on the start bit instead of being notified when reception should begin.

\$\endgroup\$
  • \$\begingroup\$ Thank you. That is good news considering my requirements. \$\endgroup\$ – Eddie Dec 15 '16 at 2:33
  • 1
    \$\begingroup\$ There is also the pin-change interrupt. \$\endgroup\$ – Janka Dec 15 '16 at 2:38
  • \$\begingroup\$ What do you mean by a pin change interrupt. How would that work? I tried using the assembly code from AVR305 but I had no success. I tried numerous baud settings. I have only been able to use a routine to successfully TX across pin \$\endgroup\$ – Eddie Dec 15 '16 at 7:37
0
\$\begingroup\$

Yes. Bit banging is the term that you could Google an find your answer.

The serial protocols I2C, SPI and uart are more or less started as simply sending a high and low on a pin. While in I2C and SPI the master controls the clock and forces the slave to receive or transmit at his own clock , where as on UART there is no common clock sharing scheme , hence each device controls it's own clock and those clock are matched according to the baud of other devices.

So what you need to know is that you could basically use any pin to make it a UART transmission but you need a synchronized clock on both the devices.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.