In Flowcode 9, some of the processor configuraton can be set in the Project Options/Configure menu (Oscillator, Watchdog, etc.) I see this creates two entries in the C code, e.g.
//Chip Configuration Settings
__PROG_CONFIG(0x1, 0x7DC);
__PROG_CONFIG(0x2, 0x1633);
I want to configure the ODCONC register of my 16F1786, which controls outputs in the C register to be open drain, specifically registers 0,1,2,3 and 7.
I would like advice on how to add a "C Code" insert into my Flow Code to accomplish this. The data sheet indicates this register is in Bank 5, 28Eh.
Thank you!
PIC 16F Chip Configuration
-
- Posts: 3
- http://meble-kuchenne.info.pl
- Joined: Wed Apr 07, 2021 12:22 am
- Location: Southern California
- Has thanked: 1 time
- Contact:
-
- Matrix Staff
- Posts: 1916
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 621 times
- Been thanked: 644 times
Re: PIC 16F Chip Configuration
Hi, ddllc
Welcome to the Flowcode forums.
Perhaps the safest way to set bits of a register within a C code block:
To clear bits:
Doing it that way you won't interfere with the other bits that may already be set or cleared.
You don't have to use binary, I just find it conveient.
For example:
etc
// is just to make a comment if not familure with C code.
Welcome to the Flowcode forums.
Perhaps the safest way to set bits of a register within a C code block:
Code: Select all
ODCONC |= 0b100000;
Code: Select all
ODCONC = ODCONC & (~0b100000);
You don't have to use binary, I just find it conveient.
For example:
Code: Select all
ODCONC |= 0x5; //hex
Code: Select all
ODCONC |= 5; //decimal
// is just to make a comment if not familure with C code.
Martin
-
- Matrix Staff
- Posts: 1916
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 621 times
- Been thanked: 644 times
Re: PIC 16F Chip Configuration
nps I was going going to state you can could also set or clear indiviaul bits with:
or
However, as Microchip has not defined the ODCONC register for 16F1786 then you can't use that method.
It's something to remember for other target devices.
Code: Select all
set_bit(ODCONC,ODC5);
st_bit(ODCONC,ODC5);
clear_bit(ODCONC,ODC5);
cr_bit(ODCONC,ODC5);
Code: Select all
set_bit(ODCONC,5);
st_bit(ODCONC,5);
clear_bit(ODCONC,5);
cr_bit(ODCONC,5);
It's something to remember for other target devices.
Martin