Menu

CLC with WS2811 demo

Help
Peter
2016-11-06
2016-11-08
  • Peter

    Peter - 2016-11-06

    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:

          'Setup CLC inputs and outputs
          SSP1DATPPS = 0x0014    'RC4->MSSP1:SDI1
          CLCIN0PPS = 0x0007     'RA7->CLC1:CLCIN0
          CLCIN1PPS = 0x0007     'RA7->CLC1:CLCIN1
          CLCIN2PPS = 0x000E     'RB6->CLC1:CLCIN2
          CLCIN3PPS = 0x000F     'RB7->CLC1:CLCIN3
          RB4PPS = 0x0009        'RB4->CCP1:CCP1
          T2AINPPS = 0x0013      'RC3->TMR2:T2IN
    
          'Setup SPI and the outout for DIN
          RB1PPS = 0x0015        'RB1->MSSP1:SDO1
          RB0PPS = 0x0014        'RB0->MSSP1:SCK1
          RC7PPS = 0x0001        'RC7->CLC1:CLC1OUT
    
          'Setup PWM
          RA0PPS = 0x000E        'RA0->PWM6:PWM6OUT
    

    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
  • Anobium

    Anobium - 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.

     
  • Peter

    Peter - 2016-11-06

    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
    • Anobium

      Anobium - 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.

       
  • Peter

    Peter - 2016-11-08

    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 :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.