Programming an atmega162 using arduino uno Post

so i have a set of step by step directions on how to reprogram / flash a AtMega 162 chip on a obd car diagnostic cable with a different upgraded firmware.

These directions mention using an arduino uno as the programmer interface, but the pins they reference are the pins labeled MISO, MOSI, SCK, GND, 5V, and RESET. it says to connect to the breakout diagnostic pins and how to set up it to reflash the chip

but the cable i have has a breakout pin headers with totally different pins.

The pins on my board are 27-PE1, 28 - GND, 12 - PD6, 13 - PD7, 14 - XTAL2, and 15 - XTAL1.

obviously after reviewing the board schematic, I can see the aformentioned pins from the instruction set are pins 1, 2, 3, 4, 6, and im assuming any of the following GND pins (16, 28, or 39)

my question is, since the diagnostic header is using a completely different set of pins, if i connect directly to the MISO / MOSI etc pins directly on the chip itself, will it still accept programming, or due to the different pins being used on this board, will it not accept programming using these different pins?

there are many different versions of this same obd diagnostic cable, and the instructions say it will work for pretty much any variation that uses the atmega162 chip, but their instructions show 3 different boards that all have a header with the miso / mosi/ sck etc pins, and not the xtal, xtal2. etc pins.

would that mean my board wont accept this same programming by being connected directly to the pins on the chip, or will it still likely work?

attached are pics of my board (the black pcb board), as well as some example boards from the instructions



It is very unclear what you are talking about. If the "board" you mention is the one containing the ATmega162, then the port shown in the photo above cannot be an ISP programming port. MISO and MOSI are on PORTB of the ATmega162.

To program the ATmega162 via ISP, you need to connect the programmer to the programming pins. Most likely the manufacturer used the JTAG interface.

This might be helpful: Programming Atmega162 Microcontroller with Arduino IDE

1 Like

Thanks for the reply.

I am fairly technical, with a bachelors in software development, but I have never attempted reflashing of any type of microchips so this is completely new territory for me.
Please forgive me for my terminology and for using terms out of place such as chip, flash, board, etc.

To put it as simply as possible, the directions are for how to use an arduino uno to flash the atmega162 chip contained on an OBD to USB Serial car diagnostic cable.

It describes step by step how to do this and i understand every step perfectly.

The instructions show multiple examples of various different brands of essentially the same OBD>USB cable, which all share the same atmega162 chip.
Each example board( pics in first post) all share the same breakout pins which allow for easier connection (MOSI, MISO, RESET, SCK, 5V)

According to the instructions, just about any variation/brand of this type of cable, so long as it contains the same atmega162 chip, can be reflashed with this upgraded firmware.

My concern is that my board also has a set of breakout pins for easier connection, but they are for totally different pins.

The reason for my post is to confirm whether or not connecting directly to the pins of the atmega chip itself listed in the instruction pdf will be able to reprogram the chip or if due to the fact the breakout pins are routed to totally different pins, which also allow reading / writing data, my concern there is that the chip might be programmed in some alternate way, and therefore not compatible with the instructions on the pdf

Like i said, I have no experience in this realm, however I do understand the process perfectly, my concern lies with the fact my cable is doesnt have these same pins on a set of breakout pins(like all the example boards do, but rather a similar set of breakout pins with totally different pins.

So if i connect to the mosi/miso etc pins directly on the atmega chip itself, ibstead of the nonexistent header pins like it shows on the instructions, will it still work or is this chip programmed using some other method involving the other set of aforementioned pins, and therefore not compatible with the walkthrough

Then follow those directions. As far as I can tell, this has nothing to do with Arduino, or the Arduino IDE, as it does not support the ATmega162.

Please post a link to where you found these mysterious directions.

1 Like

You're not alone!

a decade ago, I hired one of the best C/C++/C# developers on the planet. (along with other languages)..
BUT, he wasn’t too good with hardware - give him a screwdriver, and he’d look at it with a puzzled expression,.. almost “which end do I hold” !

He was good enough with code to be personally thanked in the foreword of Microsoft Press books !

1 Like

Since my account is new, I am unable to upload the Pdf of the instructions, but heres a link shared via my google drive
The goal of the process is to take any generic OBD>Serial K+DCAN diagnostic cable (for diagnosing BMWs using PC software)
These cables works for like 95%+ of BMWs, and all the various functions.

However, they contain a well known bug which only affects a few modules within a smaller few specific BMW models,
And unfortunately the Engine ECU module on my E92 M3 is one of those affected modules.

This firmware is a very well known upgraded firmware released opensource by a BMW community member via github.

This firmware solves the well known bug which causes these few modules to become bricked while flashing software updates to them.

I recently had to swap my Engine ECU, and so i now need to flash my original vin onto this 2nd hand module, via this K+DCAN cable, but if i attempt the procedure using the original firmware, the module will be bricked.
This upgraded firmware fixes the bugged software and will allow the flash to finish successfully

Here's the link which has the whole thing explained alot better than I just tried.

I just replied with the link but the post was placed on hold due to spam prevention.
While that post is still awaiting approval, heres the link again to the instruction pdf shared via my google drive it explains what I wrote in my post alot better than I could have so ya, hopefully that will help clarify my intention.

My only concern is that my board doesnt have the same breakout pins as the example boards on the pdf.
I just want to confirm whether the process will still work if I connect directly to the pins of the chip itself

link to instructional PDF

Thanks, now I understand. You program some Arduino to act as a programmer for the chip on the ATmega162 board.

It appears that the MOSI, MISO etc. refer to the programming Arduino, and these connect to some pins on the ATmega162 board. But I did not see a table or diagram that explains which pins on the Arduino connect to which pins on the ATmega162.

If you can find one (maybe ask the folks who publish that guide), post that. It is easy to trace out connections on a PCB using a continuity checker, then you can establish the cable connections.

The pin designations shown in one of the photos above (XTAL1, XTAL2, etc.) make no sense to me.

1 Like

okay this makes the most sense.
I received that pic with the xtal1 and xtal2 pins labeled from the seller on amazon, who claimed to have contacted their chinese manufacturer to request the pins they correspond to

After learning a bit more about this whole process, I see now that i can just pull up the Atmega162 pin reference sheet, and then continuity test it with the pin header to determine what pins they reallyare.

I'll do that when I get home, and if my hunch is correct, perhaps these header pins are indeed the same as all the other examples, and the seller just made up some nonsense.

If thats not the case, i'll just be wiring the programmer arduino directly to the actual pins on the atmega162 pins itself (MISO, MOSI, SCK, etc) and bypass the header pins completely

and hope for the best.

Thanks for pointing me in the right direction

If the ATmega162 has a bootloader, then any digital pins could be used for the data transfer (not necessarily the standard ISP programming pins MISO, MOSI, etc.).

1 Like

is there any way to easily determine whether the chip has a bootloader?
to be perfectly honest with you i dont even know what that means, but i assume that would mean the chip is modified in some way to alter the function of its pins.

What would be the purpose of doing that?
since the pins are all (as far as i had thought) easily referenceable,
What would be the purpose of modifying them besides making it potentially harder to work with

I just cant imagine any reason one would want to do that.. I guess besides more organized pcb trace layout.

All the various manufacturers of these cables I'm trying to flash are (as i understand) fairly similar.
All clones of another product.

So like that pdf shows, most cables all use the same miso, mosi, sck, reset, and vcc pins.

I cant imagine why the manufacturer of the cable i have would completely redesign the wheel, but i guess that certainly possibly they did... I'll know later tonight.

Worst case, i'll just have to purchase 1 of the cables listed in the pdf, and then flash that cable exactly as the directions lay out

Then it probably does not have a bootloader (which is simply code that uses a different protocol and generally less overhead to program the memory).

Assuming that is the case, just follow the general wiring and procedure for using ISP to program any AVR Arduino, for example this excellent tutorial.

1 Like

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