I would like to program an AT90CAN128 using Arduino IDE

Hello!
I need a little help from someone more skilled. I recovered an electronic board that contains an Atmel AT90CAN128.
https://learn.sparkfun.com/tutorials/ast-can485-hookup-guide#resources-and-going-further

Initially I even thought it was an ATMEga128, but in the end it is something similar, or rather it contains more features. At the pinout level they seem equivalent to me, maybe at the internal level they work differently. I also followed this page that contains something that interests me, instructions for programming with FTDI in Arduino IDE. I want to use this AT90CAN128 with Arduino IDE, basic programming, just a port manipulation, it would be useful because it has quite a few pins and I had in mind a project with several LEDs.
I don’t really understand everything, I’m a hobbyist, for programming in Arduino IDE would I need anything else besides FTDI? Strictly speaking about this AT90CAN128. A bootloader is mentioned, possibly, I can use a programmer like AVR USB like this one:

The schematic for the AST-CAN485 development board contains about two more ICs besides the AT90CAN128, so I don’t think it would be useful to me.
Do you think I can use the millis() or delay() functions on this AT90CAN128? Maybe even other common libraries, for a 16x2 LCD with I2C or common sensors.

For programming this microcontroller in Arduino IDE, you’ll need:

  1. FTDI Programmer (for serial communication/programming)
  2. if your board does not have a bootloader, you might need an AVR programmer like the AVR USB programmer to flash a bootloader first (like the USBasp you showed, for initial bootloader and fuse setting)
  3. Arduino IDE with appropriate board support for AT90CAN128 (add a custom board definition for AT90CAN128)
  4. Set appropriate fuses

Regarding libraries and functions:

  • millis() and delay() should work
  • Most Arduino libraries compatible with AVR should function
  • I2C and LCD libraries likely compatible
  • Sensor libraries should work with standard interfaces

Just make sure interrupts/timers don’t interfere!

ā€œ4. Set appropriate fusesā€ here I don’t really know what it’s about, I haven’t worked with something like that, but at the moment I don’t have time to deal with this chip and there’s no point in insisting. But I will soon make an attempt for programming the IC using that tool I have.
Thank you for your reply.

Hi!
Following the instructions from Sparkfun I installed the AST CAN485 ā€œboardā€ in the Arduino IDE. I had a first attempt at programming the AT90CAN128 following this configuration (I succeeded in the same manner on an ATMega8):
AT90CAN128 – USBasp
PE0(MOSI/PDI) → MOSI
PE1(MISO/PDO) → MISO
SCK → SCK
RST → RST
VCC → VCC
GND → GND
But the flashing did not complete successfully, I was getting some SCK error. I tried a ā€œBlinkā€ sketch by attaching an LED to pin 7 (PE7), if this picture is correct:

Then I followed the instructions here , roughly, I copied the files from the ā€œat90canā€ archive into the Arduino IDE (I’m running v1.8.15) but I can’t find the [usbtinyisp]AT90CAN128 or [JTAG ICE mk1]AT90CAN128 board available in Boards Manager. However, using the data above, I clicked Burn Bootloader, and something happened, the flashing shows as ā€œDone uploadingā€ but the LED still doesn’t light up. There are definitely some missing parts behind it because there are traces left:
Warning: Board arduino:avr:uat90can128 doesn’t define a ā€˜build.board’ preference. Auto-set to: AVR_UAT90CAN128
Warning: Board arduino:avr:at90can128 doesn’t define a ā€˜build.board’ preference. Auto-set to: AVR_AT90CAN128
Warning: Board arduino:avr:jat90can128 doesn’t define a ā€˜build.board’ preference. Auto-set to: AVR_JAT90CAN128
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.

I don’t have a PCB for the AT90CAN128 IC, I have a delicate setup with wires soldered to the IC pins, if I succeed in programming then I will make a PCB as well.

Correct me if I’m wrong. It sounds like you are ā€œdead buggingā€ the IC, and since it wasn’t mentioned, I’m guessing you aren’t using an external crystal oscillator? I’m speculating here based on the information provided, so if this isn’t the case, please disregard. If it is, then, continue.

From the link you provided, those instructions have you set the low nibble of the low fuse byte to 0xF which per the datasheet selects the crystal oscillator. This would be appropriate for the AST-CAN485, but in your case, the low nibble should be 0x2 to select the internal 8 MHz clock. Might also need to adjust F_CPU, but that shouldn’t keep the LED from blinking.

1 Like

I am using an external 16MHz oscillator associated with 2x capacitors of a few tens of pF.
In the Arduino IDE all I can select is:

And the sketch:

void setup() {
  // initialize digital pin 7 as an output.
  pinMode(7, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

I disconnected the Reset pin of the MCU from USBasp, as well as MOSI&MISO, so I kept only the power supply part.
I’m a hobbyist/beginner, I haven’t had to deal with fuse settings before (I’ve heard about it in principle, from documents), so I don’t have much experience in practice.

No port option, and to upload the program I proceed as follows Sketch → Upload using programmer.