I'm working on a project using an Atmega328PB microcontroller, and I've encountered a bit of a roadblock regarding UART communication. I've successfully completed the PCB design and functionality checks, but I inadvertently assigned the wrong pins for AltSoftSerial, preventing me from using it for the fourth UART I require.
Current Setup:
Hardware UARTs: 0 and 1 (fully functional)
Software UARTs:
RX1 (PB1): Pin 9 (incorrect due to AltSoftSerial issue)
TX1 (PB2): Pin 10
RX2: Pin 5 (working with software serial)
TX2: Pin 4
Goal:
I need to establish two functional software UARTs (in addition to the two hardware ones) capable of receiving data at 9600 baud. These software UARTs will primarily be used for receiving data, with minimal (or none) transmission requirements.
Challenge:
I understand that the Atmega328P has limitations regarding simultaneous software UART usage, preventing more than three (SW+HW) from operating concurrently. However, I'm wondering if the enhanced capabilities of the Atmega328PB offer a potential workaround to achieve this configuration. As I understand it, there is now no way to use AltSoftSerial, as I need ICP input, which is only PB0, PE2, and PE0, is there a way to make SoftwareSerial work, even if only receiving, but without as much data loss as with .listen()?
Thank you in advance for your time and assistance!
Thank you for the recommendation, I usually work with STMs, and they are great.
I think that NeoSWSerial, can only support one software UART at the time too, am I mistaken? Also, it doesn't support Atmega328PB, but that shouldn't be that big of an issue.
I see no obvious reason why NeoSWSerial cannot have multiple instances. However, it seems that like SoftwareSerial, only one instance can be listening at a time.
Why do you think it would not work on ATmega328PB? Try it and see.
Yeah, I guess I will have to rethink my program to switch between listened software UARTs.
What I meant by Atmega328PB not being supported is no definition for it in .cpp, but it's an easy fix, otherwise, I will try it in my project instead of basic software serial.
thank you for your help
If it's a 2 layer board, can you simply cut the PCB track to PB2 and re-route to PB0? Your RX1 will actually be TX1 so can stay the same. Or is the device you are attempting to talk to also part of the PCB? If so, simply cut the other track and re-route.
Very few of my boards are perfect first time around. There's always something to tweak, reroute, reposition etc.