Hello support team
I am using a 16F877a chip and wish to turn on the port B pull-ups.
In my C-code box I have
/*
(
option_reg=0x7F;
)
*/
This compiles without error, but the ports are not showing pull up volts.
can you help?
Joe
16F877a Pull Up
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Hello Joe
The C compiler ignores everything between /* and */ characters (they are included in the C-code box to prevent the example text from being compiled). The option_reg assignment is not being compiled or executed in this case.
All the sample text should be deleted from a C-code block and the required code written into it as you would expect to see it in the main program. Flowcode copies the contents of a C-code block directly into the main program at the appropriate location, so in this case the only contents should be the command line:
option_reg=0x7F;
After compiling a program you can use the Chip->View C... menu option to look at the C code for the full program and check how your C-code block has been placed into it.
You should be able to see that Flowcode writes a default value of 0xC0 to option_reg, but your C code will be executed later in the program and will overwrite it.
The C compiler ignores everything between /* and */ characters (they are included in the C-code box to prevent the example text from being compiled). The option_reg assignment is not being compiled or executed in this case.
All the sample text should be deleted from a C-code block and the required code written into it as you would expect to see it in the main program. Flowcode copies the contents of a C-code block directly into the main program at the appropriate location, so in this case the only contents should be the command line:
option_reg=0x7F;
After compiling a program you can use the Chip->View C... menu option to look at the C code for the full program and check how your C-code block has been placed into it.
You should be able to see that Flowcode writes a default value of 0xC0 to option_reg, but your C code will be executed later in the program and will overwrite it.
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
Re: 16F877a Pull Up
Hi,
I'm also trying to activate the weak pull-ups to port A on a 16F684:
option_reg = option_reg & 0b01111111; //enable global wpua bit !RAPU
wpua = 0b00110111; // enable all p-u's
It compiles to C fine, but to hex I get the error that wpua is not recognised:
14570-S.c(79:2): error: unknown identifier 'wpua'
14570-S.c(79:2): error: invalid operand 'wpua'
14570-S.c(79:7): error: failed to generate expression
I tried to find where the reg mnemonics are defined, they're not in the .fcd .
Any pointers to get me going?
Thanks,
Jan Didden
I'm also trying to activate the weak pull-ups to port A on a 16F684:
option_reg = option_reg & 0b01111111; //enable global wpua bit !RAPU
wpua = 0b00110111; // enable all p-u's
It compiles to C fine, but to hex I get the error that wpua is not recognised:
14570-S.c(79:2): error: unknown identifier 'wpua'
14570-S.c(79:2): error: invalid operand 'wpua'
14570-S.c(79:7): error: failed to generate expression
I tried to find where the reg mnemonics are defined, they're not in the .fcd .
Any pointers to get me going?
Thanks,
Jan Didden
-
- Valued Contributor
- Posts: 548
- Joined: Tue Jun 26, 2007 11:23 am
- Has thanked: 6 times
- Been thanked: 44 times
Re: 16F877a Pull Up
Definitions of individual device registers are in the .h file for the device in the boostc\include folder of the Flowcode installation.
In the case of the 16f684, the wpua register has been declared as wpu (not sure why).
Changing your code to refer to the wpu register should solve the compilation problem.
In the case of the 16f684, the wpua register has been declared as wpu (not sure why).
Changing your code to refer to the wpu register should solve the compilation problem.