Support for Arduino UNO R4 series
Hi
Is it possible to extend support of SBB and Serial transmission to the Arduino Uno R4 series which have a different processor?
John
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:
- Duplicate this condition
- Change the constant used to identify the MCU
- 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:
- Duplicate the 88/168/328 condition linked above
- Change the constant name used to identify the MCU
- 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
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