i have this blinking LED program (it flashes the L led every second)
#include <avr/io.h>
#include <util/delay.h>
#define DELAY 1000
int main (void) {
DDRB |= _BV(DDB5);
while(1) {
PORTB |= _BV(PORTB5);
_delay_ms(DELAY);
PORTB &= ~_BV(PORTB5);
_delay_ms(DELAY);
}
return 0;
}
this works fine but when i add a function as follows the L LED doesn't flash i intend it to. even when i remove all the code from the main function it still flashes the same way.
#include <avr/io.h>
#include <util/delay.h>
#define DELAY 1000
int main (void) {
DDRB |= _BV(DDB5);
while(1) {
PORTB |= _BV(PORTB5);
_delay_ms(DELAY);
PORTB &= ~_BV(PORTB5);
_delay_ms(DELAY);
}
return 0;
}
int test(){
return 0;
}
i use avrdude to flash the program. the processor is atmega328p. this is the Makefile that i use
defualt:
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o speaker.c
avr-gcc -o led.bin led.o
avr-objcopy -O ihex -R .eeprom led.bin led.hex
sudo avrdude -F -V -c arduino -p ATMEGA328p -P /dev/ttyACM0 -b 115200 -U flash:w:led.hex
rm led.bin
rm led.o
rm led.hex
i tried removing parameters,changing the return type,adding a prototype function, non of them worked.