SBIS for SPI

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

Currently I'm giving SPI a try, and am going by the code provided in the datasheet for the ATmega644. They used "sbis SPSR,SPIF" although the sbis command only supports the lower 32 I/O registers. I was curious why they did this if it wouldn't work? (I can simply work around this, but still wondering about it)

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

This is from the "About Code Examples" section in the datasheet:

Quote:
These code examples assume that the part specific header file is included before compilation. 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".

/Lars

Last Edited: Fri. Jan 2, 2009 - 07:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah there we go, thank you!

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

Salgat wrote:
They used "sbis SPSR,SPIF" ...
Who or what is “they”?

If you are talking about the data sheet, most ATMEL data sheets have a disclaimer somewhere in them that any program code examples might need modification to work with your particular AVR. In other words, ATMEL was too lazy to customize the assembly code examples to work for the specific processor the data sheet covers.

If you program in ATMEL assembler, there is a set of macros that will automatically straighten all this out if you choose to use them.

AVR001: Conditional Assembly and portability macros:
http://www.atmel.com/dyn/resourc...
http://www.atmel.com/dyn/resourc...

These are located on the AVR application notes page:
http://www.atmel.com/dyn/product...