I would like to assign a name to an output in CodeVision, using a macro in an easy way. Let's say #define LED RB3. How cai I do that in CV compiler ?
I would like to assign a name to an output in CodeVision, using a macro in an easy way. Let's say #define LED RB3. How cai I do that in CV compiler ?
#define LED PORTB.3
.
LED = 1;
LED = 0;
Remember to make it an output pin by DDRB.3=1;
.
Note that GCC does not support this non-standard syntax. Use the proper C bit operations for GCC.
David, thank you for your reply !
This is for CodeVion ??? Βy the way, what is the "proper C bit operations" if I use GCC ???
So, I can use the same way for inputs ?
(No problem about direction register, but thank you ... )
The C standard dictates that variable names including members of a struct must start with an alpha character thus syntax such as foo.7 is not technically possible in any C compiler. However, Codevision, like a number of embedded micro C compilers has chosen to make an exception to allow for things like PORTB.3 but in a standard compliant compiler the closest you can get is something like PORTB.bit3 or perhaps just PORTB.b3 which is often a common choice for this.
But don't worry about any of this. You use Codevision so use PORTB.3 and enjoy it.
Thread title should be 'assign a name to port pin in codevision'?
Ι apologized ... You are absolutely right. Sorry...