Positron8 - WS2812B LEDs library working with an enhanced 14-bit core device

Started by top204, Apr 07, 2024, 09:59 AM

Previous topic - Next topic

top204

I made a big, big mistake, and it is something I have advised others on the forum not to do, so my appologies. I used the proteus simulator to see if the "WS2812B.inc" library also worked with enhanced 14-bit core devices, and it failed to operate. So I, stupidly, assumed it was a fault of the library's source code and went through it with a fine tooth comb. But, Oh No it wasn't the library code's fault!.... It was the proteus simulator failing yet again to simulate a simple program correctly.

I made the mistake because the same code works in the simulator when operating on an 18F device and at the same frequency and using the same pin, so I foolishly assumed it would also work with an enhanced 14-bit core device because all the code is doing is toggling a pin fast in particular patterns for the colours. But it failed, and works perfectly on a real enhanced 14-bit core device, namely the PIC16F18857, which is a bog-standard device, and the code operates when the device is running at 16MHz, and upwards. So it will work on any enhanced 14-bit core device that has enough RAM.

The code listing below is the demonstration of twenty four WS2812B devices being manipulated so they look like the scanning red bar at the front of the KIT car in the 1970s TV show 'Night Rider', and it shows the library code operating perfectly on an enhanced 14-bit core device running at 16MHz:

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' WS2812B RGB Interface to scan a line of LEDs with illumination of the lagging LEDs decreasing gradually.
' Much like the front scanner on the KIT car of the TV program Night Rider.
'
' Written by Les Johnson for the Positron8 BASIC Compiler.
'
    Device = 16F18857                                           ' Tell the compiler what device to compile for
    Declare Xtal = 16                                           ' Tell the compiler what frequency the device is operating at (in MHz)

$define WS2812B_Pin PORTC.0                                     ' The pin used for the WS2812B chips
$define WS2812B_Amount 24                                       ' The amount of WS2812B chips to control (can be increased or decreased)

$define cRedBar   0                                             ' Make a scanning bar of colour Red
$define cGreenBar 1                                             ' Make a scanning bar of colour Green
$define cBlueBar  2                                             ' Make a scanning bar of colour Blue

    Include "WS2812B.inc"                                       ' Load the RGB WS2812B routines into the program
'
' Create global variables for the demo here
'
    Dim bChipNumber As Byte                                     ' Holds the WS2812B being communicated with
    Dim IllumArray[WS2812B_Amount] As Byte Heap                 ' Holds the bar's LED colours and brightness'

'---------------------------------------------------------------------------------------------
' The main program starts here
' Move a bar of LEDs from left to right, then right to left.
' With the LEDs behind the fully illuminated LED gradually dimming in brightness
'
Main:
    Setup()                                                     ' Setup the program and any peripherals
    Clear IllumArray                                            ' Set all the elements of IllumArray to 0
    Do
        '
        ' Move the LED bar right to left
        '
        For bChipNumber = 0 To cWS2812B_IndexAmount             ' Create a forward loop for the amount of LEDs available
            IlluminateBar(bChipNumber, cRedBar)                 ' Light up the bar of LEDs
            DelayMS 40                                          ' Add a delay to see things moving, otherwise the compiler's code is too fast and it is a blur
        Next
        '
        ' Move the LED bar left to right
        '
        For bChipNumber = cWS2812B_IndexAmount DownTo 0         ' Create a reverse loop for the amount of LEDs available
            IlluminateBar(bChipNumber, cRedBar)                 ' Light up the bar of LEDs
            DelayMS 40                                          ' Add a delay to see things moving, otherwise the compiler' code is too fast and it is a blur
        Next
    Loop

'---------------------------------------------------------------------------------------------
' Setup the program and any peripherals
' Input     : None
' Output    : None
' Notes     : None
'
Proc Setup()
    Oscillator_16MHz()                                          ' Set the device to operate at 16MHz using the internal oscillator
    WS2812B_Setup()                                             ' Setup to communicate with the WS2812B devices
EndProc

'---------------------------------------------------------------------------------------------
' Gradually Dim a specific WS2812B chip
' Input     : pIndex holds the WS2818B to examine for the dimming
'           : pColour chooses cRed, cGreen or cBlue for the colour of the scanning bar
' Output    : None
' Notes     : None
'
Proc IlluminateBar(pIndex As Byte, pColour As Byte)
    Dim bChip     As Byte
    Dim bColStore As Byte

    For bChip = cWS2812B_IndexAmount DownTo 0                   ' Scan all the WS2812B devices available
        If pIndex = bChip Then                                  ' Are we at the specific LED chip?
            IllumArray[bChip] = 255                             ' Yes. So illuminate the LED fully
        Else                                                    ' Otherwise...
            IllumArray[bChip] = IllumArray[bChip] / 2           ' Divide its value to dim the LED gradually
        EndIf
        bColStore = IllumArray[bChip]                           ' Store the contents of the array's element

        If pColour = cRedBar Then                               ' Do we want a red scanning bar?
            WS2812B_Colour(bChip, bColStore, 0, 0)              ' Yes. So illuminate the Red LED of the WS2812B chip
        ElseIf pColour = cGreenBar Then                         ' Do we want a green scanning bar?
            WS2812B_Colour(bChip, 0, bColStore, 0)              ' Yes. So illuminate the Green LED of the WS2812B chip
        Else                                                    ' Otherwise... A blue scanning bar
            WS2812B_Colour(bChip, 0, 0, bColStore)              ' So illuminate the Blue LED of the WS2812B chip
        EndIf
    Next
EndProc

'---------------------------------------------------------------------------------------------
' Set the microcontroller to 16MHz operation using its internal oscillator
' Input     : None
' Output    : None
' Notes     : For use with a PIC16F18857 device
'
Proc Oscillator_16MHz()
    OSCCON1 = %01100000
    OSCCON3 = $00
    OSCEN = $00
    OSCFRQ = %00000101                  ' HFFRQ set for 16MHz
    OSCTUNE = $00
    DelayMs 100
EndProc

'---------------------------------------------------------------------------------------------
' Set the microcontroller to 32MHz operation using its internal oscillator
' Input     : None
' Output    : None
' Notes     : For use with a PIC16F18857 device
'
Proc Oscillator_32MHz()
    OSCCON1 = %01100000
    OSCCON3 = $00
    OSCEN = $00
    OSCFRQ = %00000110                  ' HFFRQ set for 32MHz
    OSCTUNE = $00
    DelayMs 100
EndProc

'---------------------------------------------------------------------------------------------
' Setup the fuses to use the internal oscillator on a PIC16F8857 device.
' The OSC pins are general purpose I/O pins.
'
    Config1 FEXTOSC_OFF,_               ' External Oscillator not enabled
            RSTOSC_HFINT1,_             ' Power-up default value for COSC is 1MHz
            CLKOUTEN_OFF,_              ' CLKOUT function is disabled. I/O function on OSC2
            CSWEN_ON,_                  ' Writing to NOSC and NDIV is allowed
            FCMEN_ON                    ' Fail-Safe Clock Monitor Enable bit->FSCM timer enabled

    Config2 MCLRE_ON,_                  ' MCLR pin is Master Clear function
            PWRTE_OFF,_                 ' Power-up Timer disabled
            LPBOREN_OFF,_               ' Low-Power BOR disabled
            BOREN_ON,_                  ' Brown-out Reset Enabled, SBOREN bit is ignored
            BORV_LO,_                   ' Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices
            ZCD_OFF,_                   ' Zero-cross detect circuit is disabled at POR.
            PPS1WAY_OFF,_               ' The PPSLOCK bit can be cleared and set multiple times in software
            STVREN_ON,_                 ' Stack Overflow or Underflow will cause a reset
            DEBUG_OFF                   ' Background Debugger disabled

    Config3 WDTCPS_WDTCPS_31,_          ' WDT Divider ratio 1:65536. Software control of WDTPS
            WDTE_OFF,_                  ' WDT Disabled, SWDTEN is ignored
            WDTCWS_WDTCWS_7,_           ' WDT window always open (100%); software control. keyed access not required
            WDTCCS_SC                   ' WDT input clock is Software Control

    Config4 WRT_OFF,_                   ' User NVM Write protection off
            SCANE_NOT_AVAILABLE,_       ' Scanner module is off
            LVP_OFF                     ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF,_                    ' User NVM Program memory code protection disabled
            CPD_OFF                     ' Data NVM code protection disabled

Below is a video I took of the above program operating on an Amicus18 board that has a PIC16F18857 plugged into it and using its internal oscillator at 16MHz. The electrolytic capacitor on the power lines of the WS2812B devices is quite important to have, because they are very noisy when operating because their internal PWM is quite a low frequency. In projects, I actually use two 470uF capacitors on them, one at the start of the strip of them and one at the end of the strip, and this makes them very quiet, but the bigger the capacitance on the power line of them, the better, and the closer they are to them, the better.

I would be lost without my Amicus18 boards that I designed all of those years ago, because they are so easy to use and easy to replace the device in them, as long as they are 28-pin types, but I did make a smaller pin microcontroller adapted PCB a while ago for it, but I cannot find it. :-)

top204

Below is another demonstraion of a strip of WS2812B RGB LED chips being controlled by an enhanced 14-bit core device using the compiler's "WS2812B.inc" library.

The demonstration cycles the colour of 24 LEDs based upon one of three data patterns, depending on which procedure is used in the main loop:

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' WS2812B RGB Interface to cycle colours on a strip of them.
' The colour cycle type depends on which procedure is called (Cycle_Rainbow or Cycle_Power or Cycle_Sine).
'
' Written by Les Johnson for the Positron8 BASIC compiler.
'
    Device = 16F18857                                           ' Tell the compiler what device to compile for
    Declare Xtal = 16                                           ' Tell the compiler what frequency the device is operating at (in MHz)

$define WS2812B_Pin PORTC.0                                     ' The pin used for the WS2812B chips on a strip
$define WS2812B_Amount 24                                       ' The amount of WS2812B chips to control (can be increased or decreased)

    Include "WS2812B.inc"                                       ' Load the RGB WS2812B routines into the program
'
' Create global variables for the demo here
'
    Dim Cycle_bRed   As Byte                                    ' Holds the Red illumination value
    Dim Cycle_bGreen As Byte                                    ' Holds the Green illumination value
    Dim Cycle_bBlue  As Byte                                    ' Holds the Blue illumination value
    Dim wDegrees     As Word                                    ' Holds the degrees value

'---------------------------------------------------------------------------------------------
' The main program starts here
' Cycle the colours on a strip of WS2812B chips
' The colour cycle type depends on which procedure is called (Cycle_Rainbow or Cycle_Power or Cycle_Sine)
'
Main:
    Setup()                                                     ' Setup the program and any peripherals
    Do                                                          ' Create a loop
        For wDegrees = 0 To 359                                 ' Create a loop for 360 degrees
            'Cycle_Rainbow(wDegrees)                            ' Use the colour cycle based upon the Power Saving data
            'Cycle_Power(wDegrees)                              ' Use the colour cycle based upon the Rainbow data
            Cycle_Sine(wDegrees)                                ' Use the colour cycle based upon the Sine data
            DelayMS 10                                          ' A small delay to slow down the colour cycling
        Next
    Loop                                                        ' Do it forever

'---------------------------------------------------------------------------------------------
' Setup the program and any peripherals
' Input     : None
' Output    : None
' Notes     : None
'
Proc Setup()
    Oscillator_16MHz()                                          ' Set the device to operate at 16MHz using the internal oscillator
    WS2812B_Setup()                                             ' Setup to communicate with the WS2812B devices
EndProc

'---------------------------------------------------------------------------------------------
' Illuminate all the WS2812B LEDs on a strip of them
' Input     : pRed holds the illumination value for the Red LED
' Input     : pGreen holds the illumination value for the Green LED
' Input     : pBlue holds the illumination value for the Blue LED
' Output    : None
' Notes     : None
'
Proc IlluminateStrip(pRed As Byte, pGreen As Byte, pBlue As Byte)
    Dim wChip As Word                                           ' Holds the WS2812B to communicate with

    For wChip = cWS2812B_IndexAmount DownTo 0                   ' Create a loop for the amount of WS2812B devices to illiminate
        WS2812B_Colour(wChip, pRed, pGreen, pBlue)
    Next
EndProc

'---------------------------------------------------------------------------------------------
' A cycle that following the colours found in a rainbow
' Input     : pDegree holds the cycle of the colour to read from the flash memory table (0 to 359)
' Output    : None
' Notes     : None
'
Proc Cycle_Rainbow(pDegree As Word)
'
' Create a flash memory table for the RGB illumination data
'
    Dim cLights_Data As Flash8 = {0,   4,   8,   13,  17,  21,  25,  30,  34,  38,  42,  47,  51,  55,  59,  64, 68, 72, 76,
                                  81,  85,  89,  93,  98,  102, 106, 110, 115, 119, 123, 127, 132, 136, 140, 144,
                                  149, 153, 157, 161, 166, 170, 174, 178, 183, 187, 191, 195, 200, 204, 208,
                                  212, 217, 221, 225, 229, 234, 238, 242, 246, 251, 255}

    If pDegree < 60 Then
        Cycle_bRed   = 255
        Cycle_bGreen = CRead8 cLights_Data[pDegree]
        Cycle_bBlue  = 0
    ElseIf pDegree < 120 Then
        Cycle_bRed   = CRead8 cLights_Data[120 - pDegree]
        Cycle_bGreen = 255
        Cycle_bBlue  = 0
    ElseIf pDegree < 180 Then
        Cycle_bRed   = 0
        Cycle_bGreen = 255
        Cycle_bBlue  = CRead8 cLights_Data[pDegree - 120]
    ElseIf pDegree < 240 Then
        Cycle_bRed   = 0
        Cycle_bGreen = CRead8 cLights_Data[240 - pDegree]
        Cycle_bBlue  = 255
    ElseIf pDegree < 300 Then
        Cycle_bRed   = CRead8 cLights_Data[pDegree - 240]
        Cycle_bGreen = 0
        Cycle_bBlue  = 255
    Else
        Cycle_bRed   = 255
        Cycle_bGreen = 0
        Cycle_bBlue  = CRead8 cLights_Data[360 - pDegree]
    EndIf
    IlluminateStrip(Cycle_bRed, Cycle_bGreen, Cycle_bBlue)      ' Illuminate the strip of WS2812B chips
EndProc

'---------------------------------------------------------------------------------------------
' Power-saving colour cycle that helps reduce the current drain of the strip of WS2812B devices
' Input     : pDegree holds the cycle of the colour to read from the flash memory table (0 to 359)
' Output    : None
' Notes     : None
'
Proc Cycle_Power(pDegree As Word)
'
' Create a flash memory table for the RGB illumination data
'
    Dim cPower_Data As Flash8 = {0,   2,   4,   6,   8,   11,  13,  15,  17,  19,  21,  23,  25,  28,  30,  32,  34, 36, 38, 40,
                                 42,  45,  47,  49,  51,  53,  55,  57,  59,  62,  64,  66,  68,  70,  72,  74,  76, 79, 81,
                                 83,  85,  87,  89,  91,  93,  96,  98,  100, 102, 104, 106, 108, 110, 113, 115, 117,
                                 119, 121, 123, 125, 127, 130, 132, 134, 136, 138, 140, 142, 144, 147, 149,
                                 151, 153, 155, 157, 159, 161, 164, 166, 168, 170, 172, 174, 176, 178, 181,
                                 183, 185, 187, 189, 191, 193, 195, 198, 200, 202, 204, 206, 208, 210, 212,
                                 215, 217, 219, 221, 223, 225, 227, 229, 232, 234, 236, 238, 240, 242, 244,
                                 246, 249, 251, 253, 255}

    If pDegree < 120 Then
        Cycle_bRed   = CRead8 cPower_Data[120 - pDegree]
        Cycle_bGreen = CRead8 cPower_Data[pDegree]
        Cycle_bBlue  = 0
    ElseIf pDegree < 240 Then
        Cycle_bRed   = 0
        Cycle_bGreen = CRead8 cPower_Data[240 - pDegree]
        Cycle_bBlue  = CRead8 cPower_Data[pDegree - 120]
    Else
        Cycle_bRed   = CRead8 cPower_Data[pDegree - 240]
        Cycle_bGreen = 0
        Cycle_bBlue  = CRead8 cPower_Data[360 - pDegree]
    EndIf

    IlluminateStrip(Cycle_bRed, Cycle_bGreen, Cycle_bBlue)        ' Illuminate the strip of WS2812B chips
EndProc

'---------------------------------------------------------------------------------------------
' Sine wave rainbow that cycles the colours based upon a sine wave
' Input     : pDegree holds the cycle of the colour to read from the flash memory table (0 to 359)
' Output    : None
' Notes     : None
'
Proc Cycle_Sine(pDegree As Word)
'
' Create a flash memory table for the RGB illumination data
'
    Dim cSine_Data As Flash8 = {0,   0,   0,   0,   0,   1,   1,   2,
                                2,   3,   4,   5,   6,   7,   8,   9,
                                11,  12,  13,  15,  17,  18,  20,  22,
                                24,  26,  28,  30,  32,  35,  37,  39,
                                42,  44,  47,  49,  52,  55,  58,  60,
                                63,  66,  69,  72,  75,  78,  81,  85,
                                88,  91,  94,  97,  101, 104, 107, 111,
                                114, 117, 121, 124, 127, 131, 134, 137,
                                141, 144, 147, 150, 154, 157, 160, 163,
                                167, 170, 173, 176, 179, 182, 185, 188,
                                191, 194, 197, 200, 202, 205, 208, 210,
                                213, 215, 217, 220, 222, 224, 226, 229,
                                231, 232, 234, 236, 238, 239, 241, 242,
                                244, 245, 246, 248, 249, 250, 251, 251,
                                252, 253, 253, 254, 254, 255, 255, 255,
                                255, 255, 255, 255, 254, 254, 253, 253,
                                252, 251, 251, 250, 249, 248, 246, 245,
                                244, 242, 241, 239, 238, 236, 234, 232,
                                231, 229, 226, 224, 222, 220, 217, 215,
                                213, 210, 208, 205, 202, 200, 197, 194,
                                191, 188, 185, 182, 179, 176, 173, 170,
                                167, 163, 160, 157, 154, 150, 147, 144,
                                141, 137, 134, 131, 127, 124, 121, 117,
                                114, 111, 107, 104, 101, 97,  94,  91,
                                88,  85,  81,  78,  75,  72,  69,  66,
                                63,  60,  58,  55,  52,  49,  47,  44,
                                42,  39,  37,  35,  32,  30,  28,  26,
                                24,  22,  20,  18,  17,  15,  13,  12,
                                11,  9,   8,   7,   6,   5,   4,   3,
                                2,   2,   1,   1,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0,
                                0,   0,   0,   0,   0,   0,   0,   0}

    Cycle_bRed   = CRead8 cSine_Data[(pDegree + 120) // 360]
    Cycle_bGreen = CRead8 cSine_Data[pDegree]
    Cycle_bBlue  = CRead8 cSine_Data[(pDegree + 240) // 360]
    IlluminateStrip(Cycle_bRed, Cycle_bGreen, Cycle_bBlue)        ' Illuminate the strip of WS2812B chips
EndProc

'---------------------------------------------------------------------------------------------
' Set the microcontroller to 16MHz operation using its internal oscillator
' Input     : None
' Output    : None
' Notes     : For use with a PIC16F18857 device
'
Proc Oscillator_16MHz()
    OSCCON1 = %01100000
    OSCCON3 = $00
    OSCEN = $00
    OSCFRQ = %00000101                  ' HFFRQ set for 16MHz
    OSCTUNE = $00
    DelayMs 100
EndProc

'---------------------------------------------------------------------------------------------
' Set the microcontroller to 32MHz operation using its internal oscillator
' Input     : None
' Output    : None
' Notes     : For use with a PIC16F18857 device
'
Proc Oscillator_32MHz()
    OSCCON1 = %01100000
    OSCCON3 = $00
    OSCEN = $00
    OSCFRQ = %00000110                  ' HFFRQ set for 32MHz
    OSCTUNE = $00
    DelayMs 100
EndProc

'---------------------------------------------------------------------------------------------
' Setup the fuses to use the internal oscillator on a PIC16F8857 device.
' The OSC pins are general purpose I/O pins.
'
    Config1 FEXTOSC_OFF,_               ' External Oscillator not enabled
            RSTOSC_HFINT1,_             ' Power-up default value for COSC is 1MHz
            CLKOUTEN_OFF,_              ' CLKOUT function is disabled. I/O function on OSC2
            CSWEN_ON,_                  ' Writing to NOSC and NDIV is allowed
            FCMEN_ON                    ' Fail-Safe Clock Monitor Enable bit->FSCM timer enabled

    Config2 MCLRE_ON,_                  ' MCLR pin is Master Clear function
            PWRTE_OFF,_                 ' Power-up Timer disabled
            LPBOREN_OFF,_               ' Low-Power BOR disabled
            BOREN_ON,_                  ' Brown-out Reset Enabled, SBOREN bit is ignored
            BORV_LO,_                   ' Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices
            ZCD_OFF,_                   ' Zero-cross detect circuit is disabled at POR.
            PPS1WAY_OFF,_               ' The PPSLOCK bit can be cleared and set multiple times in software
            STVREN_ON,_                 ' Stack Overflow or Underflow will cause a reset
            DEBUG_OFF                   ' Background Debugger disabled

    Config3 WDTCPS_WDTCPS_31,_          ' WDT Divider ratio 1:65536. Software control of WDTPS
            WDTE_OFF,_                  ' WDT Disabled, SWDTEN is ignored
            WDTCWS_WDTCWS_7,_           ' WDT window always open (100%); software control. keyed access not required
            WDTCCS_SC                   ' WDT input clock is Software Control

    Config4 WRT_OFF,_                   ' User NVM Write protection off
            SCANE_NOT_AVAILABLE,_       ' Scanner module is off
            LVP_OFF                     ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF,_                    ' User NVM Program memory code protection disabled
            CPD_OFF                     ' Data NVM code protection disabled