This is a general question about any PIC or any FlowCode version. Personally I use v6.
How do I address a PIC register at the bit level in the flow diagram using Decision block?
For example, if we take Timer2 and we want to see/test the state of TMR2IF bit, how do you do that?
How do you make known to FlowCode environment something like “PIE1bits.TMR2IE” used in XC complier?
Only by embedding C or ASM code? If yes, then can you provide a short example code?
FlowCode seems that needs always to define variables or constants in order to use Decision block. Then how to we define/introduce/refer/make known to Flowcode environment the registers and the registers at the bit level?
Bit testing in a register
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Bit testing in a register
Hi viki2000,
With boost C compiler (8 bit pic devices):
Within a C code box, registers are in lowercase and bits are uppercase.
So perhaps one way is to first add a bool variable and assign with a bit name e.g Any_Name_You_Like (case is not important as you are just adding a flowcode variable).
Then in a C box you can assign the timer2 interrupt bit to Flowcode variable by:
Although is mixed case,
when using FCV_
the variable immediately after after FCV_ must always be in UPPERCASE.
e.g:
if variable created in flowcode is called MyVariable then you use FCV_ MYVARIABLE
the variable after = is the register and bit name you're interested in
I have created a flowchart for you to look at.
Sorry i have rushed the post as I don't have a lot of time but i hope I have made things clear enough.
Martin
With boost C compiler (8 bit pic devices):
Within a C code box, registers are in lowercase and bits are uppercase.
So perhaps one way is to first add a bool variable and assign with a bit name e.g Any_Name_You_Like (case is not important as you are just adding a flowcode variable).
Then in a C box you can assign the timer2 interrupt bit to Flowcode variable by:
Code: Select all
FCV_ANY_NAME_YOU_LIKE=pir1.TMR2IF;
Code: Select all
Any_Name_You_Like
when using FCV_
the variable immediately after after FCV_ must always be in UPPERCASE.
e.g:
if variable created in flowcode is called MyVariable then you use FCV_ MYVARIABLE
the variable after = is the register and bit name you're interested in
I have created a flowchart for you to look at.
Sorry i have rushed the post as I don't have a lot of time but i hope I have made things clear enough.
Martin
- Attachments
-
- Test Timer2 interrupt flag.fcfx
- (4.61 KiB) Downloaded 220 times
Martin
-
- Posts: 190
- Joined: Mon Jul 07, 2014 9:38 am
- Has thanked: 30 times
- Been thanked: 77 times
- Contact:
Re: Bit testing in a register
Dear Martin,
Thank you for the answer.
I tried to understand from where do you know that beside your experience. Or better said, how should I know/search such info? Where is the help file, the manual which leads to such info in case was no answer in the forum.
Well, I found next:
- the "FCV_" function can be found searching the Flowcode Help File or online here: http://www.matrixtsl.com/wiki/index.php?title=Main_Page , then will jump to C Code Icon Properties.
http://www.matrixtsl.com/wiki/index.php ... Properties
where "FCV_" is described.
- for the bit and register I found that if I click right on the name of the subroutines/Macro (as Main or another) and then I choose "See as source", then I can see how it is written/addressed inside the C code.
Thank you for the answer.
I tried to understand from where do you know that beside your experience. Or better said, how should I know/search such info? Where is the help file, the manual which leads to such info in case was no answer in the forum.
Well, I found next:
- the "FCV_" function can be found searching the Flowcode Help File or online here: http://www.matrixtsl.com/wiki/index.php?title=Main_Page , then will jump to C Code Icon Properties.
http://www.matrixtsl.com/wiki/index.php ... Properties
where "FCV_" is described.
- for the bit and register I found that if I click right on the name of the subroutines/Macro (as Main or another) and then I choose "See as source", then I can see how it is written/addressed inside the C code.