Assembly Interrupts

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

I'm beginning to learn how to do interrupts in AVR assembly, but I ran into a weird problem: I'm trying to use INT0 and INT1, and to set them to trigger on the falling edge of a signal register EICRA must be set up with 0b0000_1010. When I try to build the program I get an error: "Operand 1 out of range: 0x69", referring to the line where I'm trying to set up the register. What is this?

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

You should always post your code, so we do not need to guess. My guess is, that you try to access EICRA with "out" - use "sts" instead.

/Martin.

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

Yep, that solved the problem, thank you very much!

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

For a little clarification:

There is only a small range of memory locations that the "in" and "out" instructions can access. The in and out addresses for these registers are a modified version of the true register memory address (with fewer bits). Early on, that range was more than enough to cover all of the I/O registers.

As chips got larger and more complex, the number of registers also increased. In many of the larger devices, there are registers that the in and out instructions cannot access. So, if you use assembler, YOU have to watch out for this case. In the text register description, there is a diagram of the register and its bit structure. At the left end of the graphic for the register, you will see one or two hex numbers. For the Mega164, the PINB register has "0x03 (0x23)"; the 0x03 is the address used with in and out instructions and the 0x23 is the address used with sts and lds instructions. Similarly, in the same device, TCCR2A only has "(0xB0)"; the absence of an in/out address means that you MUST use one of the general SRAM memory access instructions for this register.

For those of you using c, you simply use the register name, and the compiler will take care of using the correct access method. There is also a macro, available, for general register access, which, I believe, will also sort this out for you. This used to be described in an AVR app note, but it is so well hidden in the "new" Atmel web site design at to be totally inaccessible.

Jim

PS: Have I said how much I REALLY, REALLY dislike the Atmel website design. Real technical information is almost impossible to find. By the way, I don't just dislike it, I HATE it! TOTALLY!

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Jim,

I was able to find the AVR app note:
http://www.atmel.com/dyn/resourc...
https://www.avrfreaks.net/index.p...

Only because I remembered it was app note number 1, Google was able to find it for me. I found the advanced search again.

When I tried the root URL of the application notes page I get this message:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.

I agree the ATMEL web site it broken and more then deserving of really being HATED.

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

Macros now posted in this thread

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

Got them!

Thanks
Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!