Solar000
Member level 2
- Joined
- Feb 6, 2013
- Messages
- 49
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Greece
- Activity points
- 1,649
Hello, i am trying to use Delay_ms function with a variable which i calculate from another function and i want to pass it to the function with the Delay_ms.
I know that Delay_ms is better from Vdelay and works with numbers and constants.
So this works :
I want to do this :
I want to make one time the calculation and pass the result from one function to another.Why it doesn't work?How i can do this, instead of calculating const y=60000/x;
to every function?
I know that Delay_ms is better from Vdelay and works with numbers and constants.
So this works :
Code:
const unsigned long y=60000/x;
Delay_ms(y);
I want to do this :
Code:
#define Tempo 60
void main(void)
{
const unsigned long DPBms=y(Tempo);
Tetarta(DPBms,4);
}
const y(const x) {
return (60000/x);
}
void Tetarta(const unsigned long Delay,int metra){
int i;
const unsigned long Tetarto=Delay; //it doesn't work.Works only if 60000/Tempo ; instead of delay variable.Also tried const Tetarto,*Delay;
metra=metra*4;
for(i = 0; i < metra; i++){
Delay_ms(Tetarto);
Movement();
}
}
I want to make one time the calculation and pass the result from one function to another.Why it doesn't work?How i can do this, instead of calculating const y=60000/x;
to every function?