mikroPascal, AVR, inverted output pin

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

mikroPascal, AVR, inverted output pin

#1 Post by mikroSeven » 09 Oct 2017 10:42

Hi, is there a way to declare an inverted output pin?

My stepper-drivers have an /EN.
var
notEnable: sbit at portB0_bit;
Not a big deal, if I want the drives to be enabled/disabled, I can code:

(1)

Code: Select all

notEnable:= 0; // enable

notEnable:= 1; // disable
Can be a bit confusing, due of using a 0 as enable and a 1 as disable. ( kind of reverse )


Other ways, 2, 3, 4:

(2)

Code: Select all

var
  notEnable: sbit at portB0_bit;

procedure doEnDisSteppers(EnDis: boolean); // 1=enable, 0= disable 
begin
  notEnable:= NOT(EnDis);
end; // doEnable

(3)

Code: Select all

var
  notEnable: sbit at portB0_bit;

procedure enableSteppers();
begin
  notEnable:= 0;
end; // enableSteppers

procedure disableSteppers();
begin
  notEnable:= 1;
end; // disableSteppers
(4)

Code: Select all

const
  cEnabled= 0;
  cDisabled = 1;
var
  notEnable: sbit at portB0_bit; 

procedure steppersEnDis(EnDis: boolean);
begin
  notEnable:= EnDis;
end; // steppersEnDis


// code
  steppersEnDis(cEnable);
//
  steppersEnDis(cDisable);



But, is there a more direct way?

I tried things like:

Code: Select all

   Enable: NOT(sbit at portB0_bit);

Code: Select all

   Enable: NOT(sbit) at portB0_bit;

Code: Select all

   Enable:sbit at NOT(portB0_bit);
Anyone a clue?
To DIY or not to DIY

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: mikroPascal, AVR, inverted output pin

#2 Post by darko.ilijevski » 10 Oct 2017 16:01

Hello

You could try something like this:

Code: Select all

program MyProject2;

const enabled : byte = 0;
const disabled : byte = 1;
var MotorEnablePin: sbit at portB0_bit;

begin
  MotorEnablePin := disabled;
end.
Best regards
BR,
Darko

Post Reply

Return to “User Projects”