How could I easily program an AT90CAN128-16AU with my tool?

Hi!
I did a search on the forum on this topic, in some cases it was successful, in others I didn't really understand the situation.
As sources of information I have these:

I wanted to give it a try, I built this circuit with AT90CAN128, the MCU is not new, it is unsoldered from a scrap board, but I still made this circuit to have easy access to the pins:


My programmer is this one [I do not know the HW/SW version]:


I also need to install a driver for it [using Zadig 2.8 and WinUSB 6.1 driver].
Connections (+ RESET, VCC and GND of course) for this AT90CAN128 (this is what I found):

MCU USB AVR
MOSI MOSI
MISO MISO
SCK SCK
Reset RST
VCC VCC
GND GND

I have also used this USBasp successfully for other MCUs such as ATMega8 or ATMega32, following the same connections.
I installed Arduino IDE 1.0.6 [the only who recognizes this MCU], I can identify the [usbtinyisp]AT90CAN128 or [JTAG ICE mk1]AT90CAN128 boards. I tried the first option, I think it is the most compatible. Normally I make the selections:

  1. Programmer → USBasp
  2. Upload using programmer (not available in older versions of IDE, but you can use Ctrl+Shift+U)

That's what I did now, and after uploading a simple sketch that should continuously lights up an LED I get confirmation "Done uploading!" but also:
avrdude: error: coult not find USB device "USBasp" with vid=0x16c0 pid=0x5dc .
From what I've noticed, the digitalWrite(pin, HIGH) function causes a voltage on that pin (~3V in general, maybe I'm wrong) but on this board I measure ~0.5V on almost all pins, on some I have ~5V (from port F).
In the end, I also managed to set the fuses accordingly (for external 16MHz oscillator):
avrdude -c usbtiny -p at90can128 -U lfuse:w:0xFF:m
avrdude -c usbtiny -p at90can128 -U hfuse:w:0x19:m
avrdude -c usbtiny -p at90can128 -U efuse:w:0xFF:m

So despite the message returned in the Arduino IDE, it seems that the MCU is not flashed.
What ideas could you give me? Is another programmer board needed? Although, as I said, if I keep everything the same, I have no problems for another MCU. Could there be a discrepancy between the Arduino IDE version and USBasp?
I have to say that I don't know much, nothing else came to mind at the moment.

Thank you!

Hi @cristian10001.

I don't have any reason to think that it would solve the problem you are having, but you might be interested to know that there is an alternative Arduino boards platform for the * AT90CAN128 microcontroller:

The 3rd party "MCUdude" platforms are of very high quality and are much used by the Arduino community.

Although I do have a good deal of experience using the "MegaCore" platform with other microcontrollers, I have never used the AT90CAN128 microcontroller so I can't say whether one or the other platform is superior for this specific target.

"MegaCore" is certainly much more modern and actively developed than the platform you are using. However, the antiquated nature of the platform you found doesn't necessarily mean it is unusable.

I'm going to ask you to provide the full verbose output from an upload.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: ☑ compile in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before when you encountered that "could not find USB device "USBasp"" error.
  6. Wait for the upload to finish.
  7. Right click on the black "Output" panel at the bottom of the Arduino IDE window.
    A context menu will open.
  8. Select Copy All from the menu.
  9. Open a reply here on this forum topic by clicking the "Reply" button.
  10. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  11. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the upload output into the code block.
  12. Move the cursor outside of the code block markup before you add any additional text to your reply.
  13. Click the "Reply" button to publish the post.

A more simple way to accomplish this is to select Tools > Burn Bootloader from the Arduino IDE menus. This feature actually performs two separate actions:

So even in the case where you don't intend to upload via a bootloader, the Burn Bootloader feature is still useful solely for the sake of setting fuses.

Binary sketch size: 520 bytes (of a 131,072 byte maximum)
C:\Program Files (x86)\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pat90can128 -cusbasp -Pusb -Uflash:w:C:\Users\Cristian\AppData\Local\Temp\build2593450677156185831.tmp\sketch_aug16a.cpp.hex:i 

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc

avrdude done.  Thank you.

As an information for the community.
Alright, this is from Arduino IDE 1.0.6 . Like I said before, this is the only version that can recognize the [usbtinyisp]AT90CAN128 or [JTAG ICE mk1]AT90CAN128 .

Regarding the MegaCore package, well IT WORKS! The MCU is functional. I did managed to successfully upload the Blink sketch into AT90CAN128. I am so happy.
I followed the instructions:

  1. Copy https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json to File→Preferences:

  1. Then went to Board Manager, searched for “MegaCore” and installed it:

Now I can select the AT90CAN128 MCU and upload the sketch using the programmer, but it also returns this:

Sketch uses 1108 bytes (0%) of program storage space. Maximum is 130560 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 4087 bytes for local variables. Maximum is 4096 bytes.
Error: cannot set sck period; please check for usbasp firmware update
Error: cannot set sck period; please check for usbasp firmware update
Warning: no eeprom data found in Intel Hex file C:\Users\Cristian\AppData\Local\arduino\sketches\E7344B9561D41B4D9364C27DB31368B8/Blink.ino.eep

I do not know if this will affect the program running.

Great news!

These messages are normal and expected. You can safely ignore them.

It may be necessary to adjust the "sck period" used by the programmer according to the clock speed of the target microcontroller. If the target is running at a very slow clock speed, and the programmer is using a low period, then this can cause the programming to fail. For this reason, the AVRDUDE tool has the ability to send commands to the USBasp to tell it to use a specific period.

This message is the AVRDUDE tool telling you that it did not receive the expected response from the USBasp when it sent a command to configure the "sck period".

One possible cause of that is the USBasp using an outdated version of the official firmware, from before support for adjusting the period via commands was implemented.

However, there is a much more common cause. The cheap Chinese USBasp clones use a proprietary firmware that automatically adjusts the period as needed. In this respect, that proprietary firmware is actually superior to the official firmware. It is a common trap for USBasp users to go through the complex process of "upgrading" their firmware after seeing this message, only to find that they actually made their programmer worse by doing that! And you can't even go back to how it was after that because the Chinese firmware is not available (though there are even better open source community firmwares).

But as long as the upload is successful, you don't need to worry about which firmware your programmer has. This would only be worth thinking about it the upload failed.

It is possible to upload data to the EEPROM memory of the microcontroller in addition to the program data you are writing to the flash memory. This message is simply telling you that you are not uploading any data to the EEPROM.

In general, we use the sketch program to write data to the EEPROM memory (MegaCore includes an "EEPROM" library that makes this easy to do). Uploading data directly to the EEPROM is something that would only be useful in certain specific applications, more common in bulk production of products than in experimentation, prototyping, and one-off projects.

If you do find the need to write data directly to the EEPROM via the USBasp, you can request assistance from the forum helpers with doing that, but otherwise just ignore the message.

For hobby projects like mine, I think your solution is good enough, I won't involve EEPROM or stuff like that.
I like to salvage and reuse components and this MCU got my attention. I will use it in the future.

Thank you for your help!

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per