You need all the PPS. Have a look at the Appnote for the use of CLC and the appnote explains how the various outputs and inputs are used to create the specific data stream for the WS2812
If you are using a PPS chip, then, you may not need to change much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wanted to do it on a 16F18313, which only has 8 pins total so it won't work if I need to assign all of those peripherals to a pin.
The application note gives the logic as (SCK & !SDO & PWM) || (SCK & SDO) and based on that I have come up with attached gate arrangement (different to the demo code though).
I put the 16F18855 CLC logic configuration from the demo file into Microchip MCC, and made the same config for the 16F18313 - all the register values were the same.
MCC generates all the configuration for the device. Using a 16F18855 it will throw loads of errors saying you haven't assigned anything in the PPS setup, whereas if using the 16F18313 you don't get any errors if you don't set anything up. So I think this is needed for some chips but not others.
The 16F18313 is missing some setup registers for Timer2:
- I don't think T2CLKCON is needed because Timer2 can only use Fosc/4 on 16F18313
- T2HLT and T2RST are not available on the 16F18313, I'm not sure how critical they are
I'll try and rig up a scope and see what's happening :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to convert my bit banging code to use CLC to drive a WS2812 LED strip.
The demo code has the following PPS code at the top:
Do you need to assign all the peripherals to a pin to use CLC, or was this just added to the demo for debugging?
If I use Microchip Code Configurator to set up CLC, it doesn't seem to require you to assign anything to physical pins on the device.
Last edit: Peter 2016-11-06
You need all the PPS. Have a look at the Appnote for the use of CLC and the appnote explains how the various outputs and inputs are used to create the specific data stream for the WS2812
If you are using a PPS chip, then, you may not need to change much.
I wanted to do it on a 16F18313, which only has 8 pins total so it won't work if I need to assign all of those peripherals to a pin.
The application note gives the logic as
(SCK & !SDO & PWM) || (SCK & SDO)
and based on that I have come up with attached gate arrangement (different to the demo code though).I'll give it a try on a chip with more pins.
Last edit: Peter 2016-11-06
The scope and the testing will tell. There may be more than one way get the data timing correct. :-)
Let us know as things progress.
I put the 16F18855 CLC logic configuration from the demo file into Microchip MCC, and made the same config for the 16F18313 - all the register values were the same.
MCC generates all the configuration for the device. Using a 16F18855 it will throw loads of errors saying you haven't assigned anything in the PPS setup, whereas if using the 16F18313 you don't get any errors if you don't set anything up. So I think this is needed for some chips but not others.
The 16F18313 is missing some setup registers for Timer2:
- I don't think T2CLKCON is needed because Timer2 can only use Fosc/4 on 16F18313
- T2HLT and T2RST are not available on the 16F18313, I'm not sure how critical they are
I'll try and rig up a scope and see what's happening :)