Page 1 of 1
How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Fri Jul 02, 2021 8:56 am
by TimN-MK
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
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Fri Jul 02, 2021 10:32 am
by BenR
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.
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Fri Jul 02, 2021 12:49 pm
by TimN-MK
Hi Ben,
That seems a bit messy, adding extra line before what sould be a simple "if" or "do while" statement?
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Thu Aug 26, 2021 11:01 am
by Steve-Matrix
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.
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Sun Sep 05, 2021 10:59 pm
by TimN-MK
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
Re: How does Flowcode handle PIC SFR's in a branch or decision?
Posted: Mon Sep 06, 2021 9:36 am
by Steve-Matrix
That will work in a C code icon or if you customise the C code in a decision icon.