E.g. I want to branch on a Comparator change, CM1CON0 but Flowcode will call it FCV_CM1CON0
- how does this get translated, do I have to create my own memory map tables? E.g 990h FCV_CM1CON0
How does Flowcode handle PIC SFR's in a branch or decision?
-
- Posts: 6
- http://meble-kuchenne.info.pl
- Joined: Fri Jun 04, 2021 5:12 pm
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 501 times
- Been thanked: 686 times
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Hello,
You can read a register into a flowcode variable like this. Lets say the variable is called reg, the C code woulld look like this.
You can read a register into a flowcode variable like this. Lets say the variable is called reg, the C code woulld look like this.
Code: Select all
FCV_REG = CM1CON0;
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Hi Ben,
That seems a bit messy, adding extra line before what sould be a simple "if" or "do while" statement?
That seems a bit messy, adding extra line before what sould be a simple "if" or "do while" statement?
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: How does Flowcode handle PIC SFR's in a branch or decision?
If you are not concerned with simulation, then there is an approach that is not 'messy'. You could add a decision icon and then simply customise the C code generated by it by right-clicking the icon and selecting the appropriate menu item. For example, you could change it to:
Flowcode does not simulate all peripheral registers and so you if you wanted to also simulate your project before downloading to the target, you would need to do a bit more work.
For example, create a variable to hold the register value and then use this in your decision icons. You can manipulate the value of this register variable using simulation-only functionality (e.g. create a property and read the value of it using the "GetValue" Built-in Function), but also add C code to set the value when running on the target. The attached is a very basic example.
Code: Select all
if (CM1CON0 & 0x02)
{
For example, create a variable to hold the register value and then use this in your decision icons. You can manipulate the value of this register variable using simulation-only functionality (e.g. create a property and read the value of it using the "GetValue" Built-in Function), but also add C code to set the value when running on the target. The attached is a very basic example.
- Attachments
-
- CM1CON0_sim.fcfx
- (7.56 KiB) Downloaded 441 times
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Steve, thanks for the extra detail on this.
Will addressing the union bitfield definitions in the pic16F18854.h also work in Flowcode?
eg:
if (CMOUTbits.MC1OUT) // Comparator out TRUE
or
if (!CMOUTbits.MC1OUT) // Comparator out FALSE
Will addressing the union bitfield definitions in the pic16F18854.h also work in Flowcode?
eg:
if (CMOUTbits.MC1OUT) // Comparator out TRUE
or
if (!CMOUTbits.MC1OUT) // Comparator out FALSE
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: How does Flowcode handle PIC SFR's in a branch or decision?
That will work in a C code icon or if you customise the C code in a decision icon.