News:

Let's find out together what makes a PIC Tick!

Main Menu

Error compiling WS2812 on 18F25K22

Started by RGV250, Sep 16, 2026, 10:42 PM

Previous topic - Next topic

RGV250

Hi,
I dug out an 18F25K22 which is 5V (for the LED strip), I tested to get the right configs (why they are not the same as 18F25K20 is beyond me).
When I tried to compile the WS2812 code I got an error
ERROR[Line136]:Item'STATUSbits_C not found!(WS2812B.INC)
I have looked in the .DEF file and it is present so not sure why there should be an error.
WS2812_Strip_18F25K22_Test.zip

Regards,
Bob

Pepe

#1
this compile ok

;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings
Device = 18F25K22

Declare Reminders Off
@ CONFIG_REQ = 0 ; Override Compiler's configuration settings
Asm-
Config FOSC = HSHP    ;HS oscillator (high power > 16 MHz)
Config PLLCFG = On    ;Oscillator multiplied by 4
Config PRICLKEN = On    ;Primary clock enabled
Config FCMEN = OFF    ;Fail-Safe Clock Monitor disabled
Config IESO = OFF    ;Oscillator Switchover mode disabled
Config PWRTEN = OFF    ;Power up timer disabled
Config BOREN = SBORDIS    ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
Config BORV = 190    ;VBOR set to 1.90 V nominal
Config WDTEN = OFF    ;Watch dog timer is always disabled. SWDTEN has no effect.
Config WDTPS = 32768    ;1:32768
Config CCP2MX = PORTC1    ;CCP2 input/output is multiplexed with RC1
Config PBADEN = OFF    ;PORTB<5:0> pins are configured as digital I/O on Reset
Config CCP3MX = PORTB5    ;P3A/CCP3 input/output is multiplexed with RB5
Config HFOFST = On    ;HFINTOSC output and ready status are not delayed by the oscillator stable status
Config T3CMX = PORTC0    ;T3CKI is on RC0
Config P2BMX = PORTB5    ;P2B is on RB5
Config MCLRE = EXTMCLR    ;MCLR pin enabled, RE3 input pin disabled
Config STVREN = On    ;Stack full/underflow will cause Reset
Config LVP = On    ;Single-Supply ICSP enabled if MCLRE is also 1
Config XINST = OFF    ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
Config Debug = OFF    ;Disabled
Config Cp0 = OFF    ;Block 0 (000800-001FFFh) not code-protected
Config CP1 = OFF    ;Block 1 (002000-003FFFh) not code-protected
Config CP2 = OFF    ;Block 2 (004000-005FFFh) not code-protected
Config CP3 = OFF    ;Block 3 (006000-007FFFh) not code-protected
Config CPB = OFF    ;Boot block (000000-0007FFh) not code-protected
Config CPD = OFF    ;Data EEPROM not code-protected
Config WRT0 = OFF    ;Block 0 (000800-001FFFh) not write-protected
Config WRT1 = OFF    ;Block 1 (002000-003FFFh) not write-protected
Config WRT2 = OFF    ;Block 2 (004000-005FFFh) not write-protected
Config WRT3 = OFF    ;Block 3 (006000-007FFFh) not write-protected
Config WRTC = OFF    ;Configuration registers (300000-3000FFh) not write-protected
Config WRTB = OFF    ;Boot Block (000000-0007FFh) not write-protected
Config WRTD = OFF    ;Data EEPROM not write-protected
Config EBTR0 = OFF    ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
Config EBTR1 = OFF    ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
Config EBTR2 = OFF    ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
Config EBTR3 = OFF    ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
Config EBTRB = OFF    ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
Endasm-
Declare Reminders On

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------   
 
 Declare Xtal = 64                           ' Tell the compiler what frequency the device is operating at (in MHz)
'
' Setup USART1
'
    Declare Hserial_Baud = 9600                 ' Set the Baud rate for USART1
    Declare HRSOut1_Pin  = PORTC.6              ' Set the pin to use for USART1 TX

$define WS2812B_Pin PORTC.0                     ' The pin used for the WS2812B chips
$define WS2812B_Amount 12                      ' The amount of WS2812B chips to control (can be increased or decreased)
                                               
$define cRedBar   0x0000FF                      ' Seconds colour (Red)
$define cGreenBar 0x00FF00                      ' Minutes colour (Green)
$define cBlueBar  0xFF0000                      ' Hours colour (Blue)

    Include "WS2812B.inc"                       ' Load the RGB WS2812B routines into the program
 
'---------------------------------------------------------------------------------------------
' The main program starts here

Main:
    WS2812B_Setup()                             ' Setup to communicate with the WS2812B devices
 
    Do                                          ' Create a loop
   
    LED_Update()    
    DelayMS 1000

    Loop

    Proc LED_Update()

            WS2812B_Colour24(1, cRedBar)               

            WS2812B_Colour24(2, cGreenBar)
                 
            WS2812B_Colour24(3, cBlueBar)      
EndProc   



RGV250

Hi Pepe,
That is strange, apart from having the config settings at the start of the program it is the same. I moved the config settings in my version to the start and that compiles as well without any other changes.

I used to put the settings at the start of the code but Les always puts them at the end so I started doing the same.

Perhaps Les can explain why this matters in this instance.

Regards,
Bob

top204

#3
Bob... You have the Device directive at the end of the code listing, so the compiler does not know what device to compile for when it is first scanning the code, so it cannot reference its .def and .ppi files correctly.

The Device directive must be at the very start of the code listing, so the parser knows what files to access, on its first pass. Otherwise, it will use defaults. It is something I will try to add errors for, because I never thought of that not being the structure of a code listing. :-)

The Config fuse settings can be anywhere, and I prefer them at the end of the code, because they are pre-parsed in the very first scan, and added to the assembler code at the very end. Also, they have no influence on the compiler at 'compile time', because they are assembler directives.

So move the 'Device = 18F25K22' directive to the top of the code listing, and it all compiles OK.

Regards
Les

RGV250

Thanks Les,
I have just had another look and think this confused me.
If I have the Device at the bottom it still shows as 18F25K22 in the "Code Explorer" but when I compile it then changes to the default 18F25K20.

I am pretty sure I will never make that mistake again.

Regards,
Bob