Setting peripheral configuration registers in code

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
fastbike
Posts: 99
Joined: 20 Aug 2004 05:28
Location: New Zealand

Setting peripheral configuration registers in code

#1 Post by fastbike » 16 Jun 2021 10:34

So, I'm looking to use a PIC16F1768/9 in a new project as it contains built in DAC and analog Comparators.

The configuration of these peripherals is done via registers. For instance if I want to invert the output of Comparator C1 I would write 1 to the C1POL bit in the CM1CON0 register (according to 19.2.3 COMPARATOR OUTPUT POLARITY in the datasheet)

Can this configuration register bit value be changed during code execution, or can it only be configured as part of the compiled program i.e. static configuration ?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Setting peripheral configuration registers in code

#2 Post by janni » 16 Jun 2021 11:57

CM1CON0 belongs to so-called SFRs (Special Function Registers) forming part of static RAM so it can be modified anytime. By 'configuration' registers (or words) in PIC processors one usually means a small range of nonvolatile (flash) memory where the basic processor configuration is stored and which (normally) should not be modified during program execution.

fastbike
Posts: 99
Joined: 20 Aug 2004 05:28
Location: New Zealand

Re: Setting peripheral configuration registers in code

#3 Post by fastbike » 16 Jun 2021 20:07

Thanks, it's been a while since I've worked with PICs. I've been down the Arduino road for several prototypes but needed a micro with 2 DACs and 4 comparators so the PIC family came up with the goods :)

Post Reply

Return to “mikroPascal PRO for PIC General”