Tecnic

Solo disponible en BuenasTareas
  • Páginas : 2 (315 palabras )
  • Descarga(s) : 0
  • Publicado : 6 de junio de 2010
Leer documento completo
Vista previa del texto
Sbit

The sbit type defines a bit within a special function register (SFR). It is used in one of the following ways:
sbit name = sfr-name ^ bit-position;

sbit name = sfr-address ^ bit-position;sbit name = sbit-address;

Where
|name |is the name of the SFR bit. |
|sfr-name |is the name of apreviously-defined SFR. |
|bit-position |is the position of the bit within the SFR. |
|sfr-address|is the address of an SFR. |
|sbit-address |is the address of the SFR bit. |

Withtypical 8051 applications, it is often necessary to access individual bits within an SFR. The sbit type provides access to bit-addressable SFRs and other bit-a ddressable objects. For

example:sbit EA= 0xAF;

This declaration defines EA as the SFR bit at address 0xAF. On the 8051, this is the enable all bit in the interrupt enable register.

Variant 1
sbit name = sfr-name ^ bit-position;The previously declared SFR (sfr-name) is the base address for the sbit. It must be evenly divisible by 8. The bit-position (which must be a number from 0-7) follows the carat symbol ('^') andspecifies the bit position to access. For example:

sfr PSW = 0xD0;

sfr IE = 0xA8;

sbit OV = PSW^2;

sbit CY = PSW^7;

sbit EA = IE^7;

Variant 2
sbit name = sfr-address ^ bit-position;

Acharacter constant (sfr-address) specifies the base address for the sbit. It must be evenly divisible by 8. The bit-position (which must be a number from 0-7) follows the carat symbol ('^') andspecifies the bit position to access. For example:

sbit OV = 0xD0^2;

sbit CY = 0xD0^7;

sbit EA = 0xA8^7;

Variant 3
sbit name = sbit-address;

A character constant (sbit-address) specifies...
tracking img