Keil compiler doesn't allow us to use sbit in declaration file (.h - header) So I am using bit in declaration of 1-bit variable in my .h (header) file and sbit in definition (.c) file for sfr . I am working on a critical project so will this cause any problem while executing on hardware?? If yes, when??
exampole on internet<code> static bit done_flag = 0; /* bit variable */
bit testfunc ( /* bit function */ bit flag1, /* bit arguments */ bit flag2) { . . . return (0); /* bit return value */ }
What do you mean, "does not allow me" ?
Show the exact, complete error message you get; and identify the line to which it relates
See: http://www.keil.com/forum/63979/
If you look at the Keil example, you'll see that they don't use extern with their sbit declarations ...
It does not allow me to use sbit as extern sbit in File 1: var1.h for above case.
As shown, C51 does allow you to have sbit definitions in a header file.
Tool set is c51
Thank you :)
File 1: var1.h
#define a= 0x125D; extern unsigned char bdata obc; extern unsigned char idata b; extern bit val0; extern bit val1; extern bit val2; extern bit val3; extern bit val4; extern bit val5; extern bit val6; extern bit val7;
File 2: var1.c
#include "var1.h" unsigned char bdata obc; unsigned char idata b; sbit val0= obc^0; sbit val1= obc^1; sbit val2= obc^2; sbit val3= obc^3; sbit val4= obc^4; sbit val5= obc^5; sbit val6= obc^6; sbit val7= obc^7;
File 3: MyProg.c
#include "var1.h" void main(void) {.......... ........... if cond...1 {........ ......... ......... } else if cond..2 {...... ....... obc=XBYTE[a] & b; ....... ....... } else {........ ......... ......... } ......... ......... }
Please look at the instructions for posting source code!
See: www.danlhenry.com/.../keil_code.png to help you.
** void main(void) not only void main
Please look, I am using as follows:
File 1: var1.h #define a= 0x125D;
extern unsigned char bdata obc; extern unsigned char idata b;
extern bit val0; extern bit val1; extern bit val2; extern bit val3; extern bit val4; extern bit val5; extern bit val6; extern bit val7;
File 2: var1.c #include "var1.h"
unsigned char bdata obc; unsigned char idata b;
sbit val0= obc^0; sbit val1= obc^1; sbit val2= obc^2; sbit val3= obc^3; sbit val4= obc^4; sbit val5= obc^5; sbit val6= obc^6; sbit val7= obc^7;
#include "var1.h"
void main
{.......... ...........
if cond...1 {........ ......... ......... }
else if cond..2 {...... ....... obc=XBYTE[a] & b; ....... ....... }
else {........ ......... ......... }
......... ......... }
Oh yes it does!
eg, Keil's own header file for the Atmel AT89C51RD2:
http://www.keil.com/dd/docs/c51/atmel/reg51rd2.h
lots of sbit declarations in there!
" I am working on a critical project" What do you mean by that?
View all questions in Keil forum