home *** CD-ROM | disk | FTP | other *** search
- /* BIO51.C
-
- Tests the in-line pre-defined functions (enabled with the '-e' option)
- of the 8051 C-compiler system.
-
- Note: ICE = Integral Constant Expression
- SFR = Special Function Register
-
- The in-line functions conceptually work like the following ANSI-type
- (casts performed automatically) function declarations:
-
- =======================================
- == Read any internal RAM/SFR address ==
- == Read value: 0 - 255 ==
- =======================================
-
- unsigned char input(ICE address);
-
-
-
- ===========================================
- == Write to any internal RAM/SFR address ==
- == Written value: 0 - 255 ==
- ===========================================
-
- void output(ICE address, unsigned char data);
-
-
-
- ===========================================
- == Read any internal RAM/SFR bit address ==
- == Read value: 0 or 1 ==
- ===========================================
-
- unsigned char read_bit(ICE bit_address);
-
-
-
- ==========================================
- == Set any internal RAM/SFR bit address ==
- ==========================================
-
- void set_bit(ICE bit_address);
-
-
-
- ============================================
- == Clear any internal RAM/SFR bit address ==
- ============================================
-
- void clear_bit(ICE bit_address);
-
-
-
- =============================================
- == Read and clear any internal RAM/SFR bit ==
- == address using the JBC instruction ==
- == Read value: 0 or 1 ==
- =============================================
-
- unsigned char read_bit_and_clear(ICE bit_address);
-
-
- */
-
- #include "io51.h"
-
- static char c;
-
- void main(void)
- {
- output(P0,c); /* Clear P0.0 - P0.7 */
- set_bit(P0_1_bit); /* Raise P0.1 */
- clear_bit(P0_1_bit); /* And down with it again */
- if (! read_bit(P0_1_bit))
- c = input(P0); /* Get that byte */
- set_bit(P0_1_bit); /* Raise P0.1 */
- if (read_bit_and_clear(P0_1_bit))
- c = input(P0); /* Get that byte */
- output(0x182,c); /* And write it into internal RAM[130] */
- }
-