FIX: Software Serial not working on Bobuino based 1284/644

If you try to use Software Serial on an ATMega1284 or ATMega644 with the Bobuino pin mapping then you will encounter a compile error.

The Macro that defines the Pin Change Interrupt causes an issue with the way in which Software Serial converts the pins being used, into hardware port pin change interrupt masks.

The following changes to the Bobuino pins.arduino.h file will fix the problem and Software Serial has been reported as working successfully.

There is also a copy of the updated Bobuino pins.arduino.h file attached to this post.

*** No guarantee or warranty is given or implied. Please back up your original files before applying these changes ***

In variants/Bobuino/pins_arduino.h, at line 66, replace :-

#define digitalPinToPCICR(p)    ifpin(p,&PCICR,(uint8_t *)0)
#define digitalPinToPCICRbit(p) ifpin(p,digital_pin_to_pcint[p] >> 3,(uint8_t *)0)
#define digitalPinToPCMSK(p)    ifpin(p,__pcmsk[digital_pin_to_pcint[]],(uint8_t *)0)
#define digitalPinToPCMSKbit(p) ifpin(p,digital_pin_to_pcint[p] & 0x7,(uint8_t *)0)

with

#define digitalPinToPCICR(p)    ifpin(p,&PCICR,(uint8_t *)0)
#define digitalPinToPCICRbit(p) ifpin(p,digital_pin_to_pcint[p] >> 3, 0)
#define digitalPinToPCMSK(p)    (((p) <= 3) ? (&PCMSK3) : (((p) <= 7) ? (&PCMSK1) : (((p) <= 9) ? (&PCMSK3) : (((p) <= 13) ? (&PCMSK1) : (((p) <= 21) ? (&PCMSK0) : (((p) <= 29) ? (&PCMSK2) : (((p) <= 31) ? (&PCMSK3) : ((uint8_t *)0))))))))
#define digitalPinToPCMSKbit(p) ifpin(p,digital_pin_to_pcint[p] & 0x7, 0)

Save the changes and recompile, then test again with Software Serial and it should now work.

pins_arduino.h (6.75 KB)