assign a name to port pin in codevision

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

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 ?

Last Edited: Sun. May 1, 2016 - 06:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 ... )

Last Edited: Sat. Apr 30, 2016 - 08:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thread title should be 'assign a name to port pin in codevision'?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ι apologized ... You are absolutely right. Sorry...