Page 1 of 1
Modify Option register at PIC16F627A with C-Box?
Posted: Thu Mar 17, 2022 9:36 pm
by dvcam99
Hello Matrix Team,
may you can help me with the above issue.
The PIC16F627A has the feature to activate the internal pulup resistors. I would like to use this feature for the complet RB-Port or may better for individual pins at the RB-Port.
May somebody can help me with the necessary C-command.
The rigister bit is number 7

- PullUp1.jpg (91.34 KiB) Viewed 4320 times
BR
Dirk
Re: Modify Option register at PIC16F627A with C-Box?
Posted: Fri Mar 18, 2022 6:56 am
by medelec35
Hi.
I have given an example
here
Are you ok with the C code to set the individual pins with a pull-up?
Re: Modify Option register at PIC16F627A with C-Box?
Posted: Fri Mar 18, 2022 12:51 pm
by dvcam99
Hi Martin,
many thanks for the replay. Not sure if I do it right. Placing the following statment inside C-Box...
OPTION_REGbits.nWPUEN = 1;
...will create the following compiler error message....
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration
Old_GSU_for_new_ECU_V1_7_1.c: main()
3008: OPTION_REGbits.nWPUEN = 1;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
int -> volatile union S31
(908) exit status = 1
(908) exit status = 1
Error returned from [xc8.exe]
Autoclose turned off
FINISHED
BR
Dirk
Re: Modify Option register at PIC16F627A with C-Box?
Posted: Fri Mar 18, 2022 1:14 pm
by medelec35
Hi.
what I posted was a link to a guide to point you in the right direction of how to use C code.
It will vary depending on the target.
In your case of the 16F627A the datasheet shows:

- WPU2.png (30.81 KiB) Viewed 4297 times
So instead of
you will need to use
Re: Modify Option register at PIC16F627A with C-Box?
Posted: Fri Mar 18, 2022 4:21 pm
by dvcam99
Yes many thanks Martin,
with RPBU it is working!!!
BR
Dirk
Re: Modify Option register at PIC16F627A with C-Box?
Posted: Fri Mar 18, 2022 4:21 pm
by dvcam99
...i mean RBPU !!!