Hi, I've a bit banging I2C implementation that uses port pins. Now I'd like to use it in several projects. But the projects have their I2C pins on different locations :-( I think there is no way to pass the address of a bit (port pin) to a function. As there is no indirect addressing in bit instructions it wouldn't help much anyway. So the only solution I have found so far is to define the I2C pins for every project and compile the module again. This is a thing I'd like to avoid. So I thought of importing an 'EXTRN bit(scl)' and declare the bit in another C-Module. So far all I've got are linker errors. Any idea how to do this? TIA Bernhard 'Gustl' Bauer
Hi, thanks for your quick response. Your link was very intresting, but didn't help much. Linker reports actually a warning: *** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL: SDAB In a C file I had: "sbit SDAB = P2^3;" I tried the combination: EXTRN NUMBER(SDAB) unsigned char idata SDAB _at_ 0xA3; It results in linker error: *** ERROR L121: IMPROPER FIXUP So I asume that the linker recognize somehow that SDAB must be inside bdata and doesn't allow greater addresses than 127. Bernhard 'Gustl' Bauer
"SDAB must be inside bdata" No - it's not! You've defined it as a bit within P2. I don't know off-hand the A51 syntax for that, but you need to get it right! I think A51 understands C51 header files, doesn't it?
In a C file I had: "sbit SDAB = P2^3;" I tried the combination: EXTRN NUMBER(SDAB) you need to include the sbit..., you can not reference it externally. Thus the sbit... should be in a .h file included in both modules. Erik
I think A51 understands C51 header files, doesn't it? Thats news for me. I just tried it. It fails on C syntax. But it seams to work on preprozessor commands.
Of what i use, it "understands" all except struct and such. I use it extensively. Even conditional assembly can be contrilled by #define. So where I used to have a .h and a .inc for C and assembly, I now have a .h with the mutually digestable stuff and a .h with the structs which the assembly does not use anyhow. This is a much safer operation than the old .h and .inc. Erik
and a .h with the structs which the assembly does not use anyhow And you could reasonably easily do away with that secondary file, too: just put (an equivalent of)
#if defined(__C51__) || defined(__CX51__) #endif