Out of Data Space

70 views
Skip to first unread message

FraserSmith51

unread,
Feb 21, 2026, 10:15:32 AMFeb 21
to jallist
Hi

I have a program running on a PIC16F18346 that contains code for driving a WS2812 string. At the moment I have 80 devices and it compiles with Code area 7298 of 16384 and Data area with 604 of 2048. This works fine on the demo rig that I have. I now want to have the program drive 146 devices but compilation failed with Out of Data Space at that. Working backwords i ended up with needing to go back to 80. Even 81 wouldn't compile. Quite confused as to why it won't work with the bigger number

As I have built this program up bit by bit I have quite a lot of the configuration and code in separate include files. I hope the ZIP file attachment has all that's needed. 

I hope that someone can shed some light on this problem.

Chers

Fraser
Ambience_Controller_WS2812.zip

pinhe...@gmail.com

unread,
Feb 21, 2026, 3:06:19 PMFeb 21
to jallist
Hi

Your arrays may not exceed the size of a ram page, which is 80 bytes.

Try using the large_array lib, but this could pose problems with the sensitive timings for the WS leds.




--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/19974d5e-88bb-4ad7-9fb7-a3f941dc9132n%40googlegroups.com.

FraserSmith51

unread,
Feb 22, 2026, 5:01:05 AMFeb 22
to jallist
Thanks Pinhead

I'll see if I can get that to work.

Cheers

Fraser

Patrick FROUCHT

unread,
Feb 22, 2026, 5:33:46 AMFeb 22
to jal...@googlegroups.com
Hello Fraser
My system is much simpler than yours but works xith. 252 ledsI have 6 main colors and up to 42 loop to get a max figure value less than 255
I have built for Christmas a string of 252 leds with various lighting effects using a PIC12F1840 
After compilation I get: Code   :3029/4096    Data:126/256  Hardware Stack : 3/16  Software Stack :80
The "only" problem I had was wanting to add a "complex" procedure : the stack system could not afford  nested procedures.

Simplify your SW leaving only the SW for the  WS2812 building up when you are satisfied with what you get.


Patrick


noname

FraserSmith51

unread,
Feb 22, 2026, 5:43:18 AMFeb 22
to jallist
OK, I now have the large arrays defined by using code from 16f1825_large_array.jal.
const WS2812B_NUM = 176
;target_cpu == PIC_16
const _large_array_core=16

const large_array_1_size = ws2812b_num
const LARGE_ARRAY_1_VARIABLE_SIZE = 1
include large_array_1
const large_array_2_size = ws2812b_num
const LARGE_ARRAY_2_VARIABLE_SIZE = 1
include large_array_2
const LARGE_ARRAY_3_VARIABLE_SIZE = 1
const large_array_3_size = ws2812b_num
include large_array_3
alias agrn is large_array_1               -- grn array
alias ared is large_array_2               -- red array
alias ablu is large_array_3               -- blu array


when I compile it fails with 
my_procedures.jal:311: Too few parameters (1 expected, 0 found)
my_procedures.jal:311: type mismatch
my_procedures.jal:311: Too few parameters (1 expected, 0 found)
my_procedures.jal:311: type mismatch
my_procedures.jal:311: Too few parameters (1 expected, 0 found)
my_procedures.jal:311: type mismatch

where 311 is the last line in the block below. It doesn't see any problem with the lines above that and it has worked before the large arrays were involved.

   for WS2812B_NUM using i loop
      if (i >= ws2812_start_1) & (i <= ws2812_finish_1) then              
         agrn[i] = byte(grn_val)
         ared[i] = byte(red_val)
         ablu[i] = byte(blu_val)
      else
         agrn[i] = 0
         ared[i] = 0
         ablu[i] = 0
      end if
   end loop

   ws2812b_refresh(agrn, ared, ablu)

What am I missing?

Cheers

Fraser

FraserSmith51

unread,
Feb 22, 2026, 6:06:50 AMFeb 22
to jallist
Hi Patrick

I would be interested in seeing your program. I am trying to get different lighting conditions for a model railway taking in a cycle of a whole day with sun and moon moving along the strip so really wanting subtle changes in colour. Not sure if your six main colours would do that so well but I guess it's worth a look at your method.

You can contact me via the MERG Tayside Area Group

Cheers

Fraser

Rob CJ

unread,
Feb 22, 2026, 12:26:49 PMFeb 22
to jallist
Hi Fraser,

I compiled your program 'setup_everithing.jal' after including your example for large array in Ambience_Controller_ws2812.jal

It compiles with a warning but that seems to be OK. Not sure if this is the whoo program since the code area seems to be very small.

jal jalv25r9 (compiled Jan 12 2025)
generating p-code
737 tokens, 475257 chars; 11841 lines; 28 files
generating PIC code pass 1
generating PIC code pass 2
39 branches checked, 0 errors
222 data accesses checked, 0 errors
6 skips checked, 0 errors
writing result
/home/rob/Tools/Jallib/lib/ws2812b_common.jal:56: warning: "WS2812B_NUM not defined, defaults to 30"
Code area: 555 of 16384 used (words)
Data area: 37 of 2048 used
Software stack available: 80 bytes
Hardware stack depth 2 of 16
0 errors, 1 warnings
 *  Press any key to close the terminal. 

Van: jal...@googlegroups.com <jal...@googlegroups.com> namens FraserSmith51 <fra...@cairntoul.net>
Verzonden: zondag 22 februari 2026 11:43
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] Out of Data Space
 

Patrick FROUCHT

unread,
Feb 22, 2026, 12:30:10 PMFeb 22
to jal...@googlegroups.com
Hi Fraser

As  told before, my program is much simpler and has only six different colors active.yellow light rust color the 
At the beginning there is a general rust yellow color then many white flashes. Then a blue red white full color in various configurations with chasing effect. 
Then the five olympic colors(white or black green red blue yellow) plus purple. Chasing each other.
I don't have the subtle evolution you are looking for.
The added file is my program and randm3.jaj which is much simpler(also less program space and time to execute) than the random.jal. 

Don't hesitate to ask

Patrick





Noel_guirlande_255_ledsX.jal
random3.jal

FraserSmith51

unread,
Feb 22, 2026, 2:58:21 PMFeb 22
to jallist
Hi Rob

Thanks for having a look at my code. Apologies as I should have said that the main part of the code is Ambience_Controller_WS2812.jal. That will give you a significantly bigger file.

Maybe that will help you to find my problem.

Thanks again

Fraser

Rob CJ

unread,
Feb 23, 2026, 1:10:54 PMFeb 23
to jallist
Hi Fraser,

It took me some time to get it compiled since the order in which files where included it did not compile in the version you sent. Maybe it was not a final version?

But I could reproduce it and the problem is caused by the fact that large array is not really an array but a trick to make a large array and apparently you cannot pass this type of array as a parameter. I tested it by using the standard data array with a limited number of bytes (<80) and then the problem is gone.

It is also the first time I ran into this issue. The solution I know at this moment if you would switch to a PIC18F. There an array can be 256 bytes per array.

Kind regards,

Rob



Verzonden: zondag 22 februari 2026 20:58

Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] Out of Data Space

FraserSmith51

unread,
Feb 23, 2026, 5:37:15 PMFeb 23
to jallist
Thanks Rob,

The program should be compiled via the Ambience_Controller_WS2812.JAL file. The program is someting that I have been working on intermittantly for several years and It really needs a big tidy up. I started with rain then added thunder. Then came the DFPlayers for trains, city sounds, Big Ben and RGB strip. The reason for recent changes has been to add WS2812 LEDs to get a sun or moon to cross the sky. The 10 chosen WS2812 LEDs work their way along the strip to give some form of directional lighting. It is supplemented by an RGB strip and shares the RGB colour values with the simpler LEDs.

It's too late in the day to start working on your suggestions but I will get back to it in the next day or so. 

Thanks again

Fraser

Mike

unread,
Feb 23, 2026, 8:59:11 PMFeb 23
to jallist
It wouldn't be difficult to code for handling separate smaller arrays, like:

if index < 74 then
    ws2812b_refresh(agrn1, ared1, ablu1)
else
    ws2812b_refresh(agrn2, ared2, ablu2)
end if

Rob CJ

unread,
Feb 24, 2026, 1:19:55 AMFeb 24
to jallist
Hi Fraser, Mike,

There is a workaround and that is using the code of ws2812b_common in your own program.

So instead of calling ws2812b_refresh() use the code of routine itself:

   var bit old_gie
   var byte i

   old_gie = INTCON_GIE                      -- save interrupt state
   INTCON_GIE = disabled                     -- temporary disable interrupts
   for WS2812B_NUM using i loop              -- all pixels
      _ws2812b_write_pixel(agrn[i], ared[i], ablu[i])
   end loop
   INTCON_GIE = old_gie                      -- restore interrupt state
   delay_10us(5)                             -- reset

So you do not pass the large array as a parameter. Mabybe nog so nice but it should work.

Kind regards,

Rob


Van: 'Mike' via jallist <jal...@googlegroups.com>
Verzonden: dinsdag 24 februari 2026 02:59

FraserSmith51

unread,
Feb 24, 2026, 3:36:09 PMFeb 24
to jallist
Hi Mike and Rob

Thank you both for your ideas as a way of getting around the size limitation. I am a member of the Model Electronic Railway Group and we have a Special Interest Group for JAL for those interested in using JAL on their railways. We had a Zoom session yesterday evening where I brought up the problem that I had encountered. There was quite a good discussion with two members suggesting alternatives -  just exactly what both of you have suggested!!!  I haven't started on re-coding yet as engaged on other things ATM but I can see that the solutions are not difficult. 

It is very useful to have access to this Forum and for there to be members like you and Patrick willing to provide support. I much appreciate it.

Thanks again

Fraser

FraserSmith51

unread,
Feb 26, 2026, 3:35:54 AMFeb 26
to jallist
I now have a program that compiles!!! Not tested yet as I need to build another circuit board as I have now used my original on a demo board with just an 80 pixel strip. This allows the "sun" or "moon" a block of 10 pixels) to travel across the sky. There is also an RGB strip that will spread the illumination. In the code below the colour values are calculated between start and end values of the three colours in the first three columns of my table. The position of my sun or moon are tracked in the last two columns. These are now based on the 146 value that I need for a bigger layout. This has been a very interesting journey that's part of a scheme where I drive four DFPlayers (using the DFPlayer library) to give a variety of sound effects (trains, city, thunder, rain, big ben), have lightning flashes with the thunder twice a day and drive two outputs for building lighting and street lighting, the latter two being modules also programmed with JAL. It is around four years since I started this project where I have just been adding bits here and there for more effects. A couple of years back I introduced the RGB strip and a white strip but the lure of the neo pixels was finally too much so the white strip has gone replaced by the neopixel strip.

const max_events = 25  
; Record definition
record lights is
   byte red
   byte grn
   byte blu
   byte pix_start
   byte pix_finish
end record

const lights lighting[max_events] = {
   {  2,  2, 50, 26, 42},;    0 clouding over
   {  2,  2, 24, 51, 68},;    1 rain
   {  0,  0,  0, 77, 93},;    2 thunderstorm
   {  0,  0,  0,102,119},;    3 thunderstorm
   {  2,  2, 50,128,144},;    4 moon light
   {  0,  0,  0,  0, 16},;    5 dawn twilight
   {100, 40,  0,  0, 16},;    6 early dawn
   {150,124,100,  7, 24},;    7 brightening
   {200,200,200, 16, 33},;    8 good sun
   {230,230,230, 24, 40},;    9 bright day
   {240,240,240, 33, 49},;    10 full sun
   {250,250,250, 40, 57},;    11 full sun
   {255,255,255, 49, 66},;    12 storm coming
   {  6,  6,  6, 58, 75},;    13 thunderstorm
   {  6,  6,  6, 68, 84},;    14 thunderstorm
   {255,255,255, 77, 93},;    15 clearing up
   {200,200,200, 86,102},;    16 bit of a dip
   {255,255,255, 95,111},;    17 full sun
   {240,240,240, 57, 66},;    18 not so bright
   {220,220,220,104,120},;    19 dimming down
   {150,150, 40,111,128},;    20 early dusk
   { 50, 20,  0,120,144},;    21 sunset
   {  0,  0,  0,  0,  9},;    22 dusk twilight
   {  2,  2, 24,  0,  9},;    23 moon light
   {  2,  2, 50, 26, 42} ;    24 rollover value
}



procedure drive_ws2812_pwm() is
   ; end of moon or end of sun reducing pixels lit as block moves
   ; to end of strip
   if index == 4 | index == 21 | then                  
      ws2812_start_1  = lighting[index].pix_start
      ws2812_finish_1 = lighting[index].pix_finish
      ws2812_diff_1   = ws2812_finish_1 - ws2812_start_1
      step_start_1    = (ws2812_diff_1 * index2) / 32
      ws2812_start_1  = lighting[index].pix_start + step_start_1
   end if
   ; start of moon or start of sun increasing pixels lit as block moves
   ; from start of strip
   if index == 5 | index == 22 then                
      ws2812_start_1  = lighting[index].pix_start
      ws2812_finish_1 = lighting[index].pix_finish
      ws2812_diff_1   = ws2812_finish_1 - ws2812_start_1
      step_start_1    = (ws2812_diff_1 * index2) / 32
      ws2812_finish_1 = lighting[index].pix_start + step_start_1
   else                                                
   ; moon or sun moves as block along the strip
      ws2812_start_1  = lighting[index].pix_start
      ws2812_start_2  = lighting[index + 1].pix_start
      ws2812_diff_1   = ws2812_start_2 - ws2812_start_1
      step_start_1    = (ws2812_diff_1 * index2) / 32
      ws2812_start_1  = lighting[index].pix_start + step_start_1

      ws2812_finish_1 = lighting[index].pix_finish
      ws2812_finish_2 = lighting[index + 1].pix_finish
      ws2812_diff_2   = ws2812_finish_2 - ws2812_finish_1
      step_finish_2   = (ws2812_diff_2 * index2) / 32
      ws2812_finish_1 = lighting[index].pix_finish + step_finish_2
   end if

   ; calculate difference between start and end values for time period
     if index2 == 0 then
      diff_red=(sword(lighting[index+1].red) - sword(lighting[index].red))
      diff_grn=(sword(lighting[index+1].grn) - sword(lighting[index].grn))
      diff_blu=(sword(lighting[index+1].blu) - sword(lighting[index].blu))
   end if

   ; calc step size for changing intensity
   ; use base value and add step each time around
   step_red = diff_red*sdword(index2) / 32                      
   red_val = byte(sdword(lighting[index].red) + step_red)        

   step_grn = diff_grn*sdword(index2) / 32
   grn_val = byte(sdword(lighting[index].grn) + step_grn)
   
   step_blu = diff_blu*sdword(index2) / 32
   blu_val = byte(sdword(lighting[index].blu) + step_blu)

   ; set the PWM values for the RGB LEDs in the block only if daytime
   if index > 4 & index < 22 then
      CCPR1 = red_val
      CCPR2 = grn_val
      CCPR3 = blu_val
   else
   ; set the PWM values for the RGB LEDs in the block to zero if night time
      CCPR1 = 0
      CCPR2 = 0
      CCPR3 = 0
   end if

   print_string(serial_hw_data,"\r\nWS2812")
   print_string(serial_hw_data,"\tred ")                                            ;tab
   print_word_dec(serial_hw_data,red_val)                                          ;print time of day
   print_string(serial_hw_data,"\tgrn ")                                            ;tab
   print_word_dec(serial_hw_data,grn_val)                                          ;print time of day
   print_string(serial_hw_data,"\tblu ")                                            ;tab
   print_word_dec(serial_hw_data,blu_val)                                          ;print time of day

   print_string(serial_hw_data,"\r\nLEDs")
   print_string(serial_hw_data,"\tred ")                                            ;tab
   print_word_dec(serial_hw_data,CCPR1)                                          ;print time of day
   print_string(serial_hw_data,"\tgrn ")                                            ;tab
   print_word_dec(serial_hw_data,CCPR2)                                          ;print time of day
   print_string(serial_hw_data,"\tblu ")                                            ;tab
   print_word_dec(serial_hw_data,CCPR3)    

   ; generate the RGB values for each pixel in the strip based on
   ; whether they are in the block or not and whether it is day or night
   for WS2812B_NUM using i loop
      ; set the RGB values for the pixels in the block
      if (i >= ws2812_start_1) & (i <= ws2812_finish_1) then  
         ; first half of strip
         if i < ws2812b_num / 2 then          
            agrn1[i] = byte(grn_val)
            ared1[i] = byte(red_val)
            ablu1[i] = byte(blu_val)
         else
            ; second half of strip
            agrn2[i - WS2812B_NUM / 2] = byte(grn_val)
            ared2[i - WS2812B_NUM / 2] = byte(red_val)
            ablu2[i - WS2812B_NUM / 2] = byte(blu_val)
         end if
      else
         ; set rest of pixels to zero
         if i < ws2812b_num / 2 then          
            agrn1[i] = 0
            ared1[i] = 0
            ablu1[i] = 0
         else
            agrn2[i - WS2812B_NUM / 2] = 0
            ared2[i - WS2812B_NUM / 2] = 0
            ablu2[i - WS2812B_NUM / 2] = 0
         end if
      end if
   end loop

   old_gie = INTCON_GIE                      -- save interrupt state
   INTCON_GIE = disabled                     -- temporary disable interrupts
   for WS2812B_NUM using i loop              -- all pixels
      if i < ws2812b_num / 2 then          
         _ws2812b_write_pixel(agrn1[i], ared1[i], ablu1[i])
      else
         _ws2812b_write_pixel(agrn2[i - WS2812B_NUM / 2], ared2[i - WS2812B_NUM / 2], ablu2[i - WS2812B_NUM / 2])
      end if
   end loop
   INTCON_GIE = old_gie                      -- restore interrupt state
   delay_10us(5)                             -- reset
end procedure


Thanks again for the help here.

Fraser

Rob CJ

unread,
Feb 26, 2026, 1:08:56 PMFeb 26
to jal...@googlegroups.com
Hi Fraser,

Good to hear that it compiles. Sounds like a great project.

It would be very nice to see a video of your project, fi you want to share that of course. If I am right you have website, correct? Not sure if you could post it there.

Kind regards,

Rob


Verzonden: donderdag 26 februari 2026 09:35

FraserSmith51

unread,
Mar 5, 2026, 3:19:47 AMMar 5
to jallist
Hi Rob

I've made a video now and placed it on Youtube as Ambiance project. Yes, I do have a website but the raw file was 2Gb. Youtube makes it a lot smaller and easier to get at. Feel free to have a look at my cycling and walking trips on my website. Please excuse the wobbles at it was difficult to keep steady for so long. My sequence starts at midnight and the first thunder storm starts at 1 o'clock. The moon hides behind clouds during the storm and comes back once the storm passes. The moon sets progressivly and then the sun rise starts. The RGB strip adds to the lighting during the day period using the same balance of colours. This version only has 80 neopixels and is mounted underneath a layout that our group takes to model railway shows. It has replaced a single white strip that used to light up the layout underneath. We now have a loco with lights and sound so we will see in May at our first show how well that works with the new lighting. 

The layout that the lighting was proposed for is in two sections. I have now made the two light bars with the RGB and WS2812 strips stuck to pieces of 25x20 aluminium angle and it works but I did spot a couple of glitches that need to be investigated. It's been an interesting project to work on with realisations of things that I could add.  

Cheers

Fraser

Rob CJ

unread,
Mar 5, 2026, 12:34:12 PMMar 5
to jallist
Hi Fraser,

Thanks for sharing. Great project.

What did you use to generated the lightning? Does not seem to be high brightness LEDs.

Kind regards,

Rob


Verzonden: donderdag 5 maart 2026 09:19

FraserSmith51

unread,
Mar 7, 2026, 11:52:26 AM (14 days ago) Mar 7
to jallist
Hi Rob

The lightning LEDs are https://www.rapidonline.com/truopto-osw35630c1a-150ma-5630-smd-led-white-120-45-60lm-150ma-5000-6000k-55-9073. With a 12V supply they are in groups of three with two dropper resistors of 47R in parallel on the stripboard as can be seen near the start of the video. They were the best fit I had available to the desired single 18R so they could be made brighter. The video has not really captured their brightness. When all the project was on a single board sitting on a table we had to turn the stripboard over as the LEDs were so bright.

Cheers

Fraser
Reply all
Reply to author
Forward
0 new messages