Interrupts in assembly not working

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

I'm trying to do PWM with an ATtiny85 and i wrote this code:

.equ PIN = (1 << PB3)
.equ TIMER0_OVF_vect = 5

.org TIMER0_OVF_vect
	rjmp test

.org 0x000000
	ldi r16, PIN
	out DDRB, r16
	out PORTB, r16
        ldi r24, 0xFF
        ldi r25, 0xFF
loop:
	rjmp loop

test:
	;do something
	reti

When i compile it it gives me this error: "Overlap in .cseg: addr=0x05 conflicts with 0x05:0x06"

Last Edited: Sun. Dec 10, 2017 - 10:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The interrupt vectors occupy the beginning of flash. You’ve declared the ovf vector which is probably at address 5 & 6 (check the datasheet) . Then you org your code at zero. This then overlaps the ovf vector. Thus the complaint.
The first instruction at addr 0 is usually a jump to skip over the vectors. Your actual code starts at an address past the vectors.

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

start simple, just put in the full list of irq vectors as shown in the datasheet...the ones not used can rjmp to reset

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:
start simple, just put in the full list of irq vectors as shown in the datasheet...the ones not used can rjmp to reset

 

Or simply make .org 0x0000 (extra point to use the actual reset vector define) an rjmp to main so that it skips over the entire vectors, so you only need to define the ones that are actually used instead of the entire set.

.org RESET_vect
    rjmp main

.org TIMER0_OVF_vect
    rjmp test

 

My digital portfolio: www.jamisonjerving.com

My game company: www.polygonbyte.com