PJON icon indicating copy to clipboard operation
PJON copied to clipboard

Support for Arduino UNO R4 series

Open fletchjp opened this issue 2 months ago • 2 comments

Hi

Is it possible to extend support of SBB and Serial transmission to the Arduino Uno R4 series which have a different processor?

John

fletchjp avatar Oct 24 '25 21:10 fletchjp

Hi @fletchjp yeah it is possible. It is relatively easy to add support for new chips: https://github.com/gioblu/PJON/blob/master/src/interfaces/ARDUINO/PJON_IO.h In particular here: https://github.com/gioblu/PJON/blob/master/src/interfaces/ARDUINO/PJON_IO.h#L97 You see how the registers are conditionally defined for the 88/168/328, you just need to:

  1. Duplicate this condition
  2. Change the constant used to identify the MCU
  3. Pass the right registers and port groups according to the datasheet

When you got the IO working, test SoftwareBitBang using the local NetworkAnalysis example. If it does not work or performance is not optimal the UNO R4 needs a custom timing configuration: https://github.com/gioblu/PJON/blob/master/src/strategies/SoftwareBitBang/Timing.h#L28

To do so:

  1. Duplicate the 88/168/328 condition linked above
  2. Change the constant name used to identify the MCU
  3. Tweak the value of SWBB_READ_DELAY.

In most cases this is enough to get it working optimally, if you cannot achieve optimal performance SWBB_BIT_WIDTH may need to be slightly tweaked on the UNO R4 side. If you have an oscilloscope you can program a Duemilanove/UNO to transmit data and measure bit width, then do the same with an R4 and adjust timing on R4 side until the durations are equal.

Be careful and always test in both directions (inverting the roles of mcu) to be sure communication works fine in both cases. Let me know how it goes and feel free to join our gitter chat for direct support if that is required: https://gitter.im/gioblu/PJON

See also the SoftwareBitBang troubleshooting section to have additional info: https://github.com/gioblu/PJON/wiki/SoftwareBitBang-troubleshooting

gioblu avatar Oct 24 '25 22:10 gioblu

Thank you for these instructions. The Arduino R4 series have a different processor family, Renesas RA4M1. I am not an expert on the internals of processors. I do know that the code needed for an encoder is different between the UNO R3 and the UNO R4.

I have a use for this. One way I could overcome this it to use R3s for PJON and link to them from the R4s using I2C. This is something I have done in the past where PJON did not work.

John

fletchjp avatar Dec 07 '25 19:12 fletchjp