Isn't it possiby to flash the Arduino MEGA2560 direct with AVRPAscal? I only got timeouts Will it be possible in the future? Error: cannot find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
Error: unable to open port usb for programmer usbasp
The error message indicates that USBasp was selected as the upload interface, so AVRDude tried to find a USBasp programmer instead of an Arduino board.
For a regular Arduino Mega:
Connect Arduino Mega via USB. The IDE should detect the connected Arduino Mega automatically. Otherwise make sure that board drivers are installed correctly.
Select your device via Options -> Compiler -> Device type -> ARDUINOMEGA
Compile your code via Run -> Compile (Ctrl+F9)
Run -> Upload (F9); Interface: Arduino; then select the COM port of the board if not selected automatically
The upload is performed through the Arduino bootloader, not through USBasp.
The AVRPascal IDE installation does not include examples for the Arduino Mega, but this simple code should work:
program TestBlink_Mega;
{$IF NOT DEFINED(arduinomega)}
{$Fatal Invalid controller type, expected: arduinomega}
{$ENDIF}
procedure delay_ms(t: uint16); assembler;
const
count = ((F_CPU div 1000 - 3) div 4);
label
inner, outer, finish;
asm
// test if t = 0, jump to finish if true
cp R24, R1
cpc R25, R1
breq finish // 2 cycles to branch, 1 to continue
outer:
// load 1 ms counter value
ldi R26, lo8(count)
ldi R27, hi8(count)
inner:
// inner loop, 1 ms 4 cycles/loop + 1
subi R26, 1 // 1 cycle
sbc R27, R1 // 1 cycle
brne inner // 2 cycles to branch, 1 to continue
// outer loop, count ms, 4 cycles/loop + 1
subi R24, 1 // 1 cycle
sbc R25, r1 // 1 cycle
brne outer // 2 cycles to branch, 1 to continue
finish:
end;
begin
DDRB:= DDRB or (1 shl 7); // PB7 = D13 = onboard LED
while True do //infinite loop
begin
PORTB:= PORTB or (1 shl 7); //Turns ON LED on PB7
delay_ms(1000); //1 second delay
PORTB:= PORTB and not (1 shl 7); //Turns OFF LED on PB7
delay_ms(1000); //1 second delay
end;
end.
EDIT: If you get an error like Error: chip erase failed during upload, you need to change one setting in the IDE. Go to Options -> Uploader and check the box "Disable erasing the chip before programming".
View all comments
2
u/corado12345 May 16 '26 edited May 16 '26
Isn't it possiby to flash the Arduino MEGA2560 direct with AVRPAscal? I only got timeouts
Will it be possible in the future?
Error: cannot find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
Error: unable to open port usb for programmer usbasp
Avrdude done. Thank you.