How can a Binary number be used in a program?
"Looks like Mr. Torfs has a typo."
I should have added that the typo is only in his commentary. As far as I know, the macros themselves are fine to use as-is (as-are?).
if You absolutotally HAVE to do it
#define bin00000001 0x01 ... define bin11111111 0xff
I do some 'binary' definitions this way
in my .h file
sfr S0_TMR2CN = 0xc8; // TIMER 2 CONTROL */ sfr S1_TMR3CN = 0xc8; // TIMER 3 CONTROL sfr S2_TMR4CN = 0xc8; // TIMER 4 CONTROL sbit SB0_TMR2CN_TF = 0xcf; sbit SB1_TMR3CN_TF = 0xcf; sbit SB1_TMR3CN_TR = 0xca; #define SM_TMRxCN_TF 0x80 // oflo/int #define SM_TMRxCN_EXF 0x40 // ext activate #define SM_TMRxCN_EXEN 0x08 // ext stimuli #define SM_TMRxCN_TR 0x04 // run control #define SM_TMRxCN_C_T 0x02 // 1 = counter 0=timer #define SM_TMRxCN_CP_RL 0x01 // 0 = reload, 1 = capture
then in the .c file
//S0_TMR2CN = 0 + SM_TMRxCN_TF + SM_TMRxCN_EXF + SM_TMRxCN_EXEN + SM_TMRxCN_TR + SM_TMRxCN_C_T + SM_TMRxCN_CP_RL; S2_TMR4CN = 0 + SM_TMRxCN_TR + SM_TMRxCN_CP_RL;