D
Dave Dunfield
That's completely off-topic here. This group is about the language
Agreed that it is OT, however some of the advice that was given,
although correct for a standard implementation, does not apply
in this situation and may confuse the OP.
Yes: Totally OT here - best to find someone familier with C on
tiny embedded controllers and ask for help.
There is no operating system in this environment, hence there is no
"standard" I/O.
There is no operating system, hence nothing to return a value to.
If main ever returns (which it shouldn't in a normal embedded system),
the system will either hang in an infinite loop or restart depending on
how it is configured.
P2 is the Special Function Register (SFR) used to access the 8051s
internal parallel I/O port #2 - defined in 8051reg.h
Actually it does - P2 is a hardware register.
Since you asked - setbit() and clrbit() are macros, not functions, which
generate a single inline assembly SETB or CLR instruction - P0.1 is
the operand to that instruction (meaning port 0 - bit 1)
8051 parallel I/O port #3.
8051 output port 0.
Regards,
Dave (Author of Micro-C)
C, not how to use it for dealing with some micro-controller. But
since there's quite a number of C issues with your code I will
comment on this.
Agreed that it is OT, however some of the advice that was given,
although correct for a standard implementation, does not apply
in this situation and may confuse the OP.
Yes: Totally OT here - best to find someone familier with C on
tiny embedded controllers and ask for help.
Non-standard header files. But then you're missing essential ones
like <stdio.h>.
There is no operating system in this environment, hence there is no
"standard" I/O.
int main( void )
Missing return statememnt here, main() is supposed to return an int.
There is no operating system, hence nothing to return a value to.
If main ever returns (which it shouldn't in a normal embedded system),
the system will either hang in an infinite loop or restart depending on
how it is configured.
'P2' has never been defined, so that already should make your compilerP2 = RowTable[row];
emit an error message.
P2 is the Special Function Register (SFR) used to access the 8051s
internal parallel I/O port #2 - defined in 8051reg.h
Lets assume you defined 'P2' to be a char. Then this function will
always return 0. So I guess the value of 'P2' must somehow be in-
fluenced by some user input (via reading the keyboard or whatever)
or it's completely useless - but your code doesn't has anything
that would make that happen.
Actually it does - P2 is a hardware register.
What's 'P0.1' supposed to be? You try to use that as the argument of
the setbit() and clrbit() functions - but it's neither a string nor
some value, so your compiler should get rather upset about that.
Since you asked - setbit() and clrbit() are macros, not functions, which
generate a single inline assembly SETB or CLR instruction - P0.1 is
the operand to that instruction (meaning port 0 - bit 1)
'P3' isn't defined anywhere in scope (and so it also hasn't a value
assigned to it).
8051 parallel I/O port #3.
Neither is 'P0' defined anywhere, nor is it's value (and, by proxy, the
value of your argument 'value') use anywhere in this function. So what's
all that supposed to be good for?
8051 output port 0.
Regards,
Dave (Author of Micro-C)