avra I/O out of range problem

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

I've used avra to program an ATmega32, but I'm kind of a newb to AVRs and have run into an odd problem. When trying to assemble a program containing

sbis TIFR,TOV1

I get an error: I/O out of range (0 <= P <= 31).
Well, it is true that TIFR is at 0x38 (56), but is
avra really crippled so badly it can't handle ports
above 31? The only posts I have found on the net regarding
this are in some East European language I can't make out.
Thanks, Tom.

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

Quote:

Well, it is true that TIFR is at 0x38 (56), but is
avra really crippled so badly it can't handle ports
above 31?

Most if not all AVR assemblers are that "crippled", as the SBIS instruction can only "reach" to register 31:

Quote:
SBIS – Skip if Bit in I/O Register is Set
Description:
This instruction tests a single bit in an I/O Register and skips the next instruction if the bit is set. This instruction operates on the lower 32 I/O Registers – addresses 0-31.

Operation:
(i) If I/O(A,b) = 1 then PC ← PC + 2 (or 3) else PC ← PC + 1

Syntax: Operands:
(i) SBIS A,b 0 ≤ A ≤ 31, 0 ≤ b ≤7

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Hi Tom,
The sbis instruction only works on the I/O registers (between 0 and 31). Same with quite a few other instructions (in, out etc).

To quote AVR datasheets:
"For I/O registers located in extended I/O map, “IN”, “OUT”, “SBIS”, “SBIC”, “CBI”, and “SBI” instructions must be replaced with instructions that allow access to extended I/O. Typically “LDS” and “STS” combined with “SBRS”, “SBRC”, “SBR”, and “CBR”."

Something like this should work for your purposes:

lds r16, TIFR
sbrs r16, TOV1

Cheers,
Plex
br

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

Thanks, guys! My face is a little red; I should have checked
that before !! But I'm learning and I appreciate your help.
AVRs have a steep learning curve compared to some other micros I've used.
Tom

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

This will help you, I think
https://www.avrfreaks.net/index.p...

I have coded for about 2 dozen architectures, and they all have their place.
Don't get too religious about them (but AVR is excellent!)

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

Oops, I see some answers snuck in while I was looking for info'!

I have coded for about 2 dozen architectures, and they all have their place.
Don't get too religious about them (but AVR is excellent!)