I have a problem with atmega32 as when i am using this code:
#include "../HAL/led/Led.h"
#define F_CPU 16000000UL
#include "../MCAL/Interrupt/ExtIntREG.h"
#include <avr/interrupt.h>
int flag = 0;
int main(void)
{
SET_BIT(MCUCR, ISC00);
SET_BIT(MCUCR, ISC01);
SET_BIT(GICR, INT0);
SET_BIT(SREG, I);
Led_init(LED0);
while(1)
{
Led_on(LED0);
}
}
/*
ISR(INT0_vect)
{
//flag = 1;
Led_on(LED2);
}
*/
i use this to test the LED if it's working without working with the interrupt just testing the LED with including the avr/interrupt.h lib but the LED is not working unless i comment the including of the library.
Edit: when disabling the interrupts but still including the interrupt header still the led doesn't work.
and this is my make file:
DEVICE = atmega32
FILENAME = APP/main
FREQ = 16000000UL
COMPILE = avr-gcc -Wall -Os -mmcu=$(DEVICE)
ADDITIONAL = BIT_MATH.h REG.h STD.h
HELPERS = MCAL/DIO/Dio.c MCAL/DIO/Dio.h
BUZZER = HAL/buzzer/Buzzer.c HAL/buzzer/Buzzer.h HAL/buzzer/BuzzerCfg.h
LED = HAL/led/Led.h HAL/led/Led.c
PUSHBUTTON = HAL/push_button/PushButton.c HAL/push_button/PushButton.h HAL/push_button/PushButtonCfg.h
LCD = HAL/lcd/Lcd.c HAL/lcd/Lcd.h HAL/lcd/LcdCfg.h
SSD = HAL/SSD/SSD.h HAL/SSD/SSDCfg.h HAL/SSD/SSD.c
INT = MCAL/Interrupt/ExtInt.c MCAL/Interrupt/ExtInt.h MCAL/Interrupt/ExtIntCfg.h MCAL/Interrupt/ExtIntREG.h
ADC = MCAL/ADC/ADC_CONFIG.h MCAL/ADC/ADC_INTERFACE.h MCAL/ADC/ADC_REG.h MCAL/ADC/ADC.c
defualt: compile upload
compile:
$(COMPILE) $(FILENAME).c $(ADDITIONAL) $(INT) $(HELPERS) $(BUZZER) $(ADC) $(LED) $(SSD) $(PUSHBUTTON) $(LCD) -o $(FILENAME).o
$(COMPILE) -o $(FILENAME).elf $(FILENAME).o -nostartfiles
avr-objcopy -j .text -j .data -O ihex $(FILENAME).elf $(FILENAME).hex
avr-size --format=avr --mcu=$(DEVICE) $(FILENAME).elf
upload:
sudo avrdude -p m32 -c usbasp -e -U flash:w:$(FILENAME).hex -F -P usb
clean:
rm $(FILENAME).o
rm $(FILENAME).elf
rm $(FILENAME).hex
when i don't use -nostartfiles
this error apears
avr-gcc -Wall -Os -mmcu=atmega32 -o APP/main.elf APP/main.o APP/main.o: In function
__vector_1': (.text+0x78): multiple definition of
__bad_interrupt' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega32.o:(.text+0x0): first defined here APP/main.o: In function__vectors': (.text+0x0): multiple definition of
__vectors' /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega32.o:(.vectors+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [makefile:19: compile] Error 1