Sketch for Atmega 328PB vs 328P

Hi everyone. I'm very new to adruino and programming, and would appreciate if someone can help.

I've a sketch that originally was made for atmega 328PB. I've made a scheme utilizing 328P and it didn't work for me. Upon invistigation, I've revealed that there are difference in pin out, and this was a reason why it didn't work on 328p.
Can someone adjust the sketch for 328p micro controller?

Welcome to the forum

Do you think it might help if you posted the sketch and explained what does not work ?

A schematic of your project and an explanation of what it should do would also be helpful

Sorry, my bad. I'm unable to attach the file as Im a new user. Here is a link to it
https://www.bimmerfest.com/forums/attachment.php?attachmentid=894559&stc=1&d=1590768626

Thanks a lot

I've checked both microcontrollers, and rx &tx pins are different: on 328pb it's pin 15&16, where on 328p they are 30 &31.

You don't need to attach a file, in fact it is better to post your sketch here to avoid the need for it to be downloaded from an external site

Please post your full sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

The PB has dual Serial. Pins 15 & 16 are TXD1 & RXD1 - pins 30 & 31 are TXD0 and RXD0, same as for P (PD0 & PD1 for both). Those MCUs were not designed to be directly pin compatible replacements.

Thanks for getting back to me on this. You are correct. I belive by correcting the sketch and indicating the correct pins should solve the problem.
I'm not the owner of this sketch and I'm not aware how to make any correction in the sketch, that is why I'm asking her for help.

My dear friend, I've 0 knowledge in making correction in the sketch. I've managed to download it to the MCU, and because it didn't work, I've started to troubleshoot and revealed this difference. I don't have any programs either to read a sketch or to edit. It will take me a long time to figure out how to make the adjustment, that is why I'm asking for help.

How did you load the sketch onto the MCU if you

I've used microchip studio software following the link below

Is this where you got the file from? DIY HOD Emulator for Traffic Jam Assistant (TJA) | BimmerFest BMW Forum

If so, it seems to be making use of TXD1 and RXD1 so I don't think that you have much chance that some simple changes in an ELF file will do the job.

Yes, you are absolutely correct.

Why do you think that it will not be possible?

PB1 pin out for both MCUs is the same and it's giving me 5v as it was suppose to do. The only change here is the tx and rx.
You might be right, I'm not sure myself, that is why trying to get some help here.

Thanks for your comment.

The ATmega328P does not have a second serial port. However, you could try using SoftwareSerial, which requires modifying the source code.

Would appreciate if you can guide me..

Please post the C/C++ source code, using code tags (post editor <code> button.

What program i can use to extract it from elf file?

The original C/C++ source code can't be extracted from the elf file. Ask the authors for the code.

Alternatively, you could buy the designated ATmega328PB board and simply get on with the project.

Looks like this will be the best solution. Thanks for your comment.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.