Can Microchip's CLC use 'virtual' ports? - Page 1
Forum section: electronics / general

author: woody
author_rank: Frequent Contributor
timestamp: October 09, 2025, 08:46:20 am
content: Hi,Maybe a silly question/remark, but anyway.I use the CLC functionality of the PIC (e.g. PIC18F04Q41) often in projects. Typically when I want a peripheral to perform some fast action without code intervention. Timers that end, NCOs that overflow. The CLC works fine for that.One thing though strikes me as strange: the CLC can take inputs from most internal peripherals without sacrificing a physical pin but AFAIK I always need a physical pin when I want a 'programmable' input to the CLC. For instance, if I want to combine the output of the NCO with a signal originating from the firmware, for the latter I always need to appoint a physical port as an input to the CLC . That port can then be accessed from firmware. So it takes a real pin that is not necessarily used for anything else (although handy during debugging) which is a pity, the more so if you use a couple of CLC's in a 14 pins PIC.To me it would seem logical to be able to use a virtual input to the CLC that can be accessed from the code. But either these don't exist or I managed to miss completely how this should be done.Any ideas are welcome :-)

author: JPortici
author_rank: Super Contributor
timestamp: October 09, 2025, 09:12:23 am
content: ISTR they did add a virtual GPIO for this reason, but i don't remember which devices... (Edit: the Q24)In any case you should be able to do it anyway.. you should have the option to set the CLC data input as a fixed zero or one, alternate the two values

author: woody
author_rank: Frequent Contributor
timestamp: October 09, 2025, 02:26:35 pm
content: Quote from: JPortici on October 09, 2025, 09:12:23 amUnfortunately I cannot find any mention of virtual GPIOs in either the PIC18F26/45/46/55/56Q24 or a PIC24 DS, which probably says something about my searching powers. May I ask where did you see this?About your suggestion on how to do it anyway on a 16F or 18F, I have to say that is a great solution. I implemented it right away. Thanks for the heads-up!

author: JPortici
author_rank: Super Contributor
timestamp: October 09, 2025, 03:27:56 pm
content: PORTW

author: woody
author_rank: Frequent Contributor
timestamp: October 09, 2025, 03:41:05 pm
content: Ah, the Signal Routing Port. Who would have thoughtThanks!

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 09, 2025, 03:48:01 pm
content: The more complex CLB peripheral on the 16F13xxx parts (and hopefully more to come) do have some dedicated inputs and a register to write to them.

author: woody
author_rank: Frequent Contributor
timestamp: October 09, 2025, 04:01:23 pm
content: Yes, I came across a Microchip video on these this morning. Sure looks interesting, when taking into account the price and that they come in 8/14/20 pin packages.

author: Picuino
author_rank: Super Contributor
timestamp: October 09, 2025, 07:16:05 pm
content: This Microchip peripheral is a stroke of genius. Especially considering the current lack of inexpensive and versatile PAL and GAL circuits.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 09, 2025, 08:48:26 pm
content: Quote from: Picuino on October 09, 2025, 07:16:05 pmYes - you can treat it like a PLD with free MCU thrown in...The online tool works reasonably well, though it's hard to tell when it's about to run out of resources to fit the device.I recently used it to decode dummy LEDs in a stream of WS2812 data to do routing between multiple LED strips - like railway points.

author: Picuino
author_rank: Super Contributor
timestamp: October 10, 2025, 12:51:10 pm
content: CLCIN0PPS to CLCIN3PPS allow you to select 4 random pins for inputs:https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/PIC18F04-05-14-15Q41-Microcontroller-Data-Sheet-DS40002242.pdfTable 22-2. CLC Input SelectionPage 34121.8.1 xxxPPSPage 326

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 10, 2025, 12:54:15 pm
content: Quote from: Picuino on October 10, 2025, 12:51:10 pmYes, but you need to have a spare physical pin. It would be nice to have a few internal port pins to do this. There are also cases where some peripheral pins can be routed to pins but not directly to CLC inputs.