delay
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: delay
Hello Franky,
The C compiler supports shorter delays.
You will need to add a C Code icon to your flowchart and enter something similar to the following code:
delay_10us(12);
This would generate a 120us delay.
There is a delay_us() function that works in a similar way, but the C compiler will not accept it unless the clock frequency can be divided exactly.
You can pass Flowcode variables to these functions if required. Example:
A global Flowcode variable, Var1, would be declared as FCV_VAR1 in the C code - delay_10us(FCV_VAR1);
A local (macro) Flowcode variable, Var2, would be declared as FCL_VAR2 in the C code.
The C compiler supports shorter delays.
You will need to add a C Code icon to your flowchart and enter something similar to the following code:
delay_10us(12);
This would generate a 120us delay.
There is a delay_us() function that works in a similar way, but the C compiler will not accept it unless the clock frequency can be divided exactly.
You can pass Flowcode variables to these functions if required. Example:
A global Flowcode variable, Var1, would be declared as FCV_VAR1 in the C code - delay_10us(FCV_VAR1);
A local (macro) Flowcode variable, Var2, would be declared as FCL_VAR2 in the C code.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: delay
Hello Franky
You simply need to add a C code icon to your program and then add the following to the contents of the icon.
delay_10us(x);
Where x is the number of micro seconds x 10 you wish to delay for.
Alternativly there is
delay_us(x);
Where x is the number of micro seconds you wish to delay for. In v3 the clock speed must divide exactly to allow this function to compile.
You simply need to add a C code icon to your program and then add the following to the contents of the icon.
delay_10us(x);
Where x is the number of micro seconds x 10 you wish to delay for.
Alternativly there is
delay_us(x);
Where x is the number of micro seconds you wish to delay for. In v3 the clock speed must divide exactly to allow this function to compile.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: delay
When you use a C block, and place a statement e.g. delay_10us(15); notice the semicolon after the bracket, that's missing. Just add it and recompile.
Each C statment requires a semicolon (;) at the end.
Each C statment requires a semicolon (;) at the end.
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: delay
Hello
If time is a byte variable then you would use like this...
Otherwise you would use like this.
If time is a byte variable then you would use like this...
Code: Select all
delay_10us(FCV_TIME);
Code: Select all
while (FCV_TIME > 255)
{
FCV_TIME = FCV_TIME - 255;
delay_10us(255);
}
delay_10us(FCV_TIME);
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel