Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoftwareBitBang Atmega32A support #372

Open
Nume1977 opened this issue Dec 12, 2020 · 1 comment
Open

SoftwareBitBang Atmega32A support #372

Nume1977 opened this issue Dec 12, 2020 · 1 comment
Labels

Comments

@Nume1977
Copy link

I really love this protocol, and recently i updated one of my projects from a Atmega328p to a Atmega32A (44 pin variant), but it is not supported by Pjon (throws erros when compiling, mainly because of "'PJON_IO_PIN_TO_PORT_REG' was not declared in this scope" ) and my guess is because of the pinouts.

This chip is available on the MightyCore boards along with the 1244/644/324/164 etc.

Is there any change for this chip to be supported, or point me in the right way to add the pin settings?

@gioblu gioblu added the port label Dec 12, 2020
@gioblu
Copy link
Owner

gioblu commented Dec 12, 2020

Ciao @Nume1977 thank you for your compliments and welcome :)
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 ATmega32 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 ATmega32A side.

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 gioblu changed the title Support for Atmega32A SoftwareBitBang Atmega32A support Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants