ADC interrupt not working on ATtiny85

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wrote this:

.equ SDA = (1 << PB4)
.equ SCK = (1 << PB2)
.equ ADCIN = (1 << PB3)
.equ TIMER0_COMPB_vect = 11
.equ ADC_vect = 8
.equ START = 15

.org 0x000000
	rjmp START

.org ADC_vect
	rjmp adcdone

.org START
	ldi r16, (SCK | SDA)
	out DDRB, r16
	out PORTB, r18
	;pwm setup
	ldi r16, (2<<COM0A0 | 2<<COM0B0 | 3<<WGM00)
	out TCCR0A, r16
	ldi r16, (0<<WGM02 | 1<<CS00)
	out TCCR0B, r16
	ldi r16, (0<<PWM1A | 0<<COM1A0 | 1<<CS10)
	out TCCR1, r16
	ldi r16, (1<<PWM1B | 2<<COM1B0)
	out GTCCR, r16
	ldi r16, 15
	out OCR1B, r16
	;pwm setup end
	;adc setup
	ldi r16, ((1 << ADLAR) | (1 << MUX0) | (1 << MUX1))
	sts ADMUX, r16
	ldi r16, ((1 << ADEN) | (1 << ADPS1) | (1 << ADPS2) | (1 << ADIE) | (1 << ADSC))
	sts ADCSRA, r16
	;adc setup end
	sei
	ldi r16, SDA
	ldi r17, SCK
	ldi r24, 0xFF
	ldi r25, 0xFF
	ldi r26, 0x02
	rcall delay
	ldi r25, 0x00
	ldi r26, 0x00
loop:
	;rcall shiftout
	rjmp loop

delay:
	sts 0x0200, r24
	sts 0x0201, r25
	sts 0x0202, r26
	sts 0x0203, r27
delay1:
	sbiw r25:r24, 1
	brcc delay1
	lds r24, 0x0200
	lds r25, 0x0201
	sbiw r27:r26, 1
	brcc delay1
	lds r26, 0x0202
	lds r27, 0x0203
	ret

adcdone:
	lds r20, ADCH
	out OCR1B, r20
	lds r20, ADCSRA
	ori r20, (1 << ADSC)
	sts ADCSRA, r20
	reti

The pwm is working perfectly, but the ADC_vect interrupt isn't being called, anybody knows how to fix this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why are you redefining everything in the device header? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not, ADC_vect isn't defined by default

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it is. Atmel do not call it "ADC_vect".

 

See the inc.def file. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This in fact... 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, i'm now using ADCCaddr, but it still doesn't work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nevermind, got it to work by changing STS to OUT and LDS to IN, i don't know why i used these

Last Edited: Sun. Dec 10, 2017 - 02:39 PM