My sketch was uploading fine with ctrl+shift++U.
Today it is giving an error during upload.
My code is
/*
ATmega8@16MHz_7seg_4digit
*/
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdio.h>
#define LED_Directions DDRD /* define LED Direction */
#define LED_Direction DDRB /* define LED Direction */
#define LED_PORT1 PORTD /* define LED port */
#define LED_PORT2 PORTB /* define LED port */
int segments[] = {0b10111111, 0b10000110, 0b11011011, 0b11001111, 0b11100110, 0b11101101, 0b11111101, 0b10000111, 0b11111111, 0b11101111};
int k, j, i, h, factor;
int brightvalue = 0;
void set_brightness()
{
int brightness = brightvalue;
while (0 < brightness)
{
_delay_us(1);
--brightness;
}
}
ISR(TIMER0_OVF_vect)
{
PORTB = (1 << PB0);
PORTD = segments[k];
set_brightness();
PORTB = (1 << PB1);
PORTD = segments[j];
set_brightness();
PORTB = (1 << PB2);
PORTD = segments[i];
set_brightness();
PORTB = (1 << PB3);
PORTD = segments[h];
set_brightness();
}
void SevenSeg_SetNumber(int num)
{
k = num % 10;
num = num / 10;
j = num % 10;
num = num / 10;
i = num % 10;
num = num / 10;
h = num % 10;
num = num / 10;
}
int main(void)
{
sei();
DDRD = 0xff; /* define port direction is output */
DDRB = 0xff; /* define port direction is output */
PORTD = 0x00;
PORTB = 0x00;
TIMSK = (1 << TOIE0); /* Enable Timer0 overflow interrupts */
TCNT0 = 0; /* load TCNT0, count for 10ms*/
TCCR0 = (1 << CS02); /* start timer0 with /256 prescaler*/
brightvalue = 1000; /* set brightness level of 7 segment display */
while (1)
{
SevenSeg_SetNumber(2500);/* set value to display */
}
}
the error message is
Arduino: 1.8.11 (Windows 10), Board: "ATmega8, Yes (UART0), BOD 2.7V, LTO disabled, 16 MHz external"
D:\Arduino_1.8.11\arduino-1.8.11\arduino-builder -dump-prefs -logger=machine -hardware D:\Arduino_1.8.11\arduino-1.8.11\hardware -hardware D:\Arduino_1.8.11\arduino-"C:\\Users\\Karanbir\\AppData\\Local\\Temp\\arduino_build_138578\\sketch\\SevSegArrayTest.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\Karanbir\AppData\Local\Temp\arduino_cache_352303\core\core_64f4847de77d63802f23cfd9351c6407.a
D:\\Arduino_1.8.11\\arduino-1.8.11\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Karanbir\\AppData\\Local\\Temp\\arduino_build_138578/SevSegArrayTest.ino.elf" "C:\\Users\\Karanbir\\AppData\\Local\\Temp\\arduino_build_138578/SevSegArrayTest.ino.hex"
"D:\\Arduino_1.8.11\\arduino-1.8.11\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\Karanbir\\AppData\\Local\\Temp\\arduino_build_138578/SevSegArrayTest.ino.elf"
Sketch uses 516 bytes (6%) of program storage space. Maximum is 7680 bytes.
Global variables use 30 bytes (2%) of dynamic memory, leaving 994 bytes for local variables. Maximum is 1024 bytes.
D:\Arduino_1.8.11\arduino-1.8.11\hardware\tools\avr/bin/avrdude -CD:\Arduino_1.8.11\arduino-1.8.11\hardware\tools\avr/etc/avrdude.conf -v -patmega8 -cusbasp -Pusb -Uflash:w:C:\Users\Karanbir\AppData\Local\Temp\arduino_build_138578/SevSegArrayTest.ino.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "D:\Arduino_1.8.11\arduino-1.8.11\hardware\tools\avr/etc/avrdude.conf"
Using Port : usb
Using Programmer : usbasp
AVR Part : ATmega8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
efuse 0 0 0 0 no 0 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9307 (probably m8)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: reading input file "C:\Users\Karanbir\AppData\Local\Temp\arduino_build_138578/SevSegArrayTest.ino.hex"
avrdude: writing flash (516 bytes):
Writing | ################################################## | 100% 6.56s
avrdude: 516 bytes of flash written
avrdude: verifying flash memory against C:\Users\Karanbir\AppData\Local\Temp\arduino_build_138578/SevSegArrayTest.ino.hex:
avrdude: load data flash data from input file C:\Users\Karanbir\AppData\Local\Temp\arduino_build_138578/SevSegArrayTest.ino.hex:
avrdude: input file C:\Users\Karanbir\AppData\Local\Temp\arduino_build_138578/SevSegArrayTest.ino.hex contains 516 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 4.88s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x12
avrdude: verification error; content mismatch
avrdude done. Thank you.
the selected serial port
does not exist or your board is not connected
I have truncated the error to fit the 9000 challenge.