This commit is contained in:
2020-12-17 15:53:34 +13:00
parent 167b48703f
commit e6bfdccc61
3 changed files with 30 additions and 20 deletions

View File

@@ -3,12 +3,13 @@ F_CPU=8000000
PROG=dragon_jtag PROG=dragon_jtag
DEBUGGER = dragon DEBUGGER = dragon
PORT=/dev/ttyUSB0 PORT=/dev/ttyUSB0
TYPE?=DEBUG
CC=avr-g++ CC=avr-g++
OBJCOPY=avr-objcopy OBJCOPY=avr-objcopy
CFLAGS=-Wall -g -mmcu=${MCU} -DF_CPU=${F_CPU} -I. CFLAGS=-Wall -g -O -mmcu=${MCU} -DF_CPU=${F_CPU} -I. -std=gnu++11 -D${TYPE} -Wno-write-strings
TARGET=main TARGET=main
SRCS=src/*.cpp test/main.cpp SRCS=src/*.cpp test/main.cpp
default: build flash default: build flash
@@ -24,8 +25,11 @@ clean:
rm -f bin/* rm -f bin/*
debug: flash avarice debug: flash avarice
sleep 1
avr-gdb -ex "target remote :4242" bin/main.elf avr-gdb -ex "target remote :4242" bin/main.elf
avarice: avarice:
avarice --file bin/main.elf --part ${MCU} --${DEBUGGER} :4242 sleep 1
avarice --file bin/main.elf --part ${MCU} --${DEBUGGER} :4242 &
term:
screen /dev/ttyUSB0 1000000

View File

@@ -10,22 +10,32 @@ namespace photointerrupter {
TCCR2 |= (1<<CS20); //No prescale TCCR2 |= (1<<CS20); //No prescale
OCR2 |= 105; OCR2 |= 105;
//DDRB |= (1<<PB3); //DDRB |= (1<<PB3);
DDRD |= (1<<PD6)|(1<<PD7); DDRD |= (1<<PD7);
//TIMSK |= (1<<OCIE0);
//TIMSK |= (1<<OCIE2);
MCUCR |= (1<<ISC11)|(1<<ISC10); //INT1 rising edge MCUCR |= (1<<ISC11)|(1<<ISC10); //INT1 rising edge
GICR |= (1<<INT1); GICR |= (1<<INT1);
sei(); sei();
} }
ISR(TIMER2_COMP_vect) { // ISR(TIMER2_COMP_vect) {
volatile static int count; // cli();
count++; // volatile static int count;
if(count == 60) TCCR2 &= ~(1<<CS20); // count++;
if(count > 600) { // if(count == 60) {
TCCR2 |= (1<<CS20); // GICR &= ~(1<<INT1);
count = 0; // TCCR2 &= ~(1<<COM20);
} // }
} // if(count > 660) {
// TCCR2 |= (1<< COM20);
// GICR |= (1<<INT1);
// count = 0;
// }
// sei();
// }
} // namespace photointerrupter } // namespace photointerrupter

View File

@@ -9,16 +9,12 @@ int main()
{ {
photointerrupter::init(); photointerrupter::init();
DDRD |= (1<<PD6); DDRD |= (1<<PD6);
while(1); while(1);
return 0; return 0;
} }
PHOTOINTERRUPT { PHOTOINTERRUPT {
cli();
PORTD |= (1<<PD6); PORTD |= (1<<PD6);
_delay_ms(100); _delay_ms(100);
PORTD &= ~(1<<PD6); PORTD &= ~(1<<PD6);
GIFR |= (1<<INTF1);
sei();
} }