Modify Option register at PIC16F627A with C-Box?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
dvcam99
Posts: 89
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 11:03 am
Has thanked: 6 times
Been thanked: 12 times

Modify Option register at PIC16F627A with C-Box?

Post 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
PullUp1.jpg (91.34 KiB) Viewed 1998 times
BR

Dirk
Happy FC9, FC-8 and FC-6 professional user ;)

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Modify Option register at PIC16F627A with C-Box?

Post 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?
Martin

dvcam99
Posts: 89
Joined: Fri Dec 04, 2020 11:03 am
Has thanked: 6 times
Been thanked: 12 times

Re: Modify Option register at PIC16F627A with C-Box?

Post 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
Happy FC9, FC-8 and FC-6 professional user ;)

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Modify Option register at PIC16F627A with C-Box?

Post 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
WPU2.png (30.81 KiB) Viewed 1975 times
So instead of

Code: Select all

OPTION_REGbits.nWPUEN = 1;
you will need to use

Code: Select all

OPTION_REGbits.nRBPU = 1;
Martin

dvcam99
Posts: 89
Joined: Fri Dec 04, 2020 11:03 am
Has thanked: 6 times
Been thanked: 12 times

Re: Modify Option register at PIC16F627A with C-Box?

Post by dvcam99 »

Yes many thanks Martin,

with RPBU it is working!!! :D

BR

Dirk
Happy FC9, FC-8 and FC-6 professional user ;)

dvcam99
Posts: 89
Joined: Fri Dec 04, 2020 11:03 am
Has thanked: 6 times
Been thanked: 12 times

Re: Modify Option register at PIC16F627A with C-Box?

Post by dvcam99 »

...i mean RBPU !!!
Happy FC9, FC-8 and FC-6 professional user ;)

Post Reply