It would be most convenient if the
Delay_us() and Delay_ms() routines could take variables, not just constant expressions.
Bengt
Delay_us() and Delay_ms() only take constant parameters
- nemanja.nikolic
- Posts: 171
- Joined: 01 Dec 2014 10:50
Re: Delay_us() and Delay_ms() only take constant parameters
Hello,
You can use delay routines with variables, you can use following function:
Look at help.
Nemanja.
Best regards.
You can use delay routines with variables, you can use following function:
Code: Select all
unsignedpause = 1000;
...
Vdelay_ms(pause); // ~ one second pause
Nemanja.
Best regards.
Re: Delay_us() and Delay_ms() only take constant parameters
Hi, I tried this:
procedure TestDelay1(const sTestDelay: dword);
begin
Delay_us(sTestDelay);
end;
procedure TestDelay2;
var zTestDelay: dword;
begin
zTestDelay := 1000;
Delay_us(zTestDelay);
end;
Both procedures fail to compile and the compiler message is:
Syntax error: Expected "constant expression" but "complex expression" found
procedure TestDelay1(const sTestDelay: dword);
begin
Delay_us(sTestDelay);
end;
procedure TestDelay2;
var zTestDelay: dword;
begin
zTestDelay := 1000;
Delay_us(zTestDelay);
end;
Both procedures fail to compile and the compiler message is:
Syntax error: Expected "constant expression" but "complex expression" found
- nemanja.nikolic
- Posts: 171
- Joined: 01 Dec 2014 10:50
Re: Delay_us() and Delay_ms() only take constant parameters
Hello,
You can't use Delay_ms() with variables.
Look at simple example:
Nemanja.
Best regards.
You can't use Delay_ms() with variables.
Look at simple example:
Code: Select all
program Vdelay;
var cnt: word;
begin
cnt := 1;
while TRUE do
begin
cnt := cnt + 1;
Vdelay_ms(cnt);
end;
end.
Best regards.
Re: Delay_us() and Delay_ms() only take constant parameters
Yes, finally we agree
If you read my first post, you will see that this is exactly my point.
Delay_us() and Delay_ms() can only take constant expressions, not variables.
Which is my reason for writing this post here in the wish list.
It would be most convenient if the Delay_us() and Delay_ms() routines could take variables, not just constant expressions.
Could you please pass this on to the developers?
Thanks,
Bengt
If you read my first post, you will see that this is exactly my point.
Delay_us() and Delay_ms() can only take constant expressions, not variables.
Which is my reason for writing this post here in the wish list.
It would be most convenient if the Delay_us() and Delay_ms() routines could take variables, not just constant expressions.
Could you please pass this on to the developers?
Thanks,
Bengt
- nemanja.nikolic
- Posts: 171
- Joined: 01 Dec 2014 10:50
Re: Delay_us() and Delay_ms() only take constant parameters
Hello,
Because of that we have another routine for variable: Vdelay_ms();
Nemanja.
Best regards.
Because of that we have another routine for variable: Vdelay_ms();
Nemanja.
Best regards.
Re: Delay_us() and Delay_ms() only take constant parameters
Ah, thanks, that certainly helps for millisecond delays.
Then my wish for the future is a delay routine for variables, that takes microsecond delays.
Thanks,
Bengt
Then my wish for the future is a delay routine for variables, that takes microsecond delays.
Thanks,
Bengt
- nemanja.nikolic
- Posts: 171
- Joined: 01 Dec 2014 10:50
Re: Delay_us() and Delay_ms() only take constant parameters
Hello,
For microsecond would not be so exact.
You can create function for that if you haven't much values and if your values isn't too small (more larger then 1/Fosc).
For example:
Nemanja.
Best regards.
For microsecond would not be so exact.
You can create function for that if you haven't much values and if your values isn't too small (more larger then 1/Fosc).
For example:
Code: Select all
procedure Delay_VAR(VAR : word);
case VAR of
1: begin
Delay_us(100);
end;
2: begin
Delay_us(200);
end;
3: begin
Delay_us(300);
end;
.
.
.
.
end;
end;
Nemanja.
Best regards.
Re: Delay_us() and Delay_ms() only take constant parameters
Why it is made with constand and not Var?
Where is the benefit?
Why not only the delay Version with Variable?
Are the Nachteile Disadvantages?
Where is the benefit?
Why not only the delay Version with Variable?
Are the Nachteile Disadvantages?
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Delay_us() and Delay_ms() only take constant parameters
Hi,
Because there were precision issues when using variables instead of constants.
Regards,
Ivan.
Because there were precision issues when using variables instead of constants.
Regards,
Ivan.