0

I need to define virtual port or variable bind with [porta.1,porta.2,portc.1,portc.2] Because some pins of all available port in micro controller(PIC18F4550) in in use and i have not any free port;

I need help in C programming for embeded(mikrocForPIC is my IDE). I need something like below:

#define myport=[Porta.1+Porta.2+Portc.1+Portc.2]

.
.
.

and use for:

myport++;
myport<<1;

I remember it was able but i cant remember what is true syntax!?

please help

thanks

m s
  • 65
  • 1
  • 9
  • Instead of posting some confusing pseudocode, can you please state what you want to accomplish in plain English? Then we could help you with what the code constructs could be. – Ross Jun 05 '14 at 16:49
  • Do you agee that this is strictly denpendent on microcontroller and compiler. You didn't specify nothing of them. – harper Jun 05 '14 at 17:55
  • 1
    @Harper it's tagged with [pic] and [mikroc], so I think that tiny portion is defined... – Ross Jun 05 '14 at 18:03
  • some people are too smart some people is too stupid,Dont wory ! – m s Jun 24 '14 at 15:17

1 Answers1

1

If you want to use a specific BIT in one of the available port, you use (In MikroC), sbit PORTA1 at RA1_bit;

sbit is a compiler reserved word which means that you specify a single bit in a byte.

"PortA1" could be anything. You use this to give a name to the bit you specified.

at is a compiler reserved word, gives the path of the name you created.

RA1_bit is the actual definition of the PORTA-1 bit in MikroC, exemple a PIC.

You can't virtually "create" a port which is not available on the MCU. You can define a variable that is equal to the value of the port.

 //#define PortValue PORTA

PortValue, in the code, will always have the same value as the actual physical "PortA".

OR, in the code, define a variable, let's say unsigned char, which is equal to the value of the port. You'll then be able to play around with your variable.

UC ucPort;

ucPort = PORTA; //Specific to MIKROC for PIC. May be different in other compilers.
mmohab
  • 2,303
  • 4
  • 27
  • 43
Jean-francois
  • 316
  • 1
  • 9