Serial Hardware and SPI not working together

5 views
Skip to first unread message

FraserSmith51

unread,
Jan 25, 2026, 7:08:20 AMJan 25
to jallist
Hi,

I'm working with a PIC16F18323 that's driving a short strip of WS2812 LEDs using SPI. To help with debugging I want to have a serial connection to my desktop to see what's happening. The problem is that the serial and SPI don't seem to want to work together.If I comment out the SPI and WS2182 bits the serial works and if I comment out the serial stuff the WS2812 bits don't work. Jal file attached.

Any ideas as to what the problem is? I started with a 18313 but the 18323 offered the opportunity of more pins.

TIA

Fraser
16f18313_ws2812b_spi.jal

Patrick FROUCHT

unread,
Jan 25, 2026, 10:34:27 AMJan 25
to jal...@googlegroups.com
Hi Fraser

I understand your problem with simultaneous use of serial and SPI.

I worked with 252  WS2812 LEDs in my example (Noel guirlande) so take it to see if you can have some solution to debug SPI and leds.

I also made a simpler project with  WS2812 LEDs for the Delorean car to make a visual animation for a friend, I used only 8   WS2812 LEDs.

I also made for another friend the illumination of the Eiffel Tower for the olympic games.
16f1827_SW2812b_Dada-tour-Eiffel-X.jal.

I used the  SPI and the library made for the WS2812 Leds.
Take care of all pin naming and I did my own library (slightly modified the jal library  for 16F1827 SSP1CON has to be SSP1CON1) 

--
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/add793b1-05a5-4cac-b129-714615da575bn%40googlegroups.com.
Noel_guirlande_252_ledsX.jal
16f1827_SW2812b_DeLorean.jal
16f1827_SW2812b_Dada-tour-Eiffel-X.jal
ws2812b_spi_16F1827.jal

FraserSmith51

unread,
Jan 25, 2026, 11:47:13 AMJan 25
to jallist
Whoops, I see an error in my posting. With the serial deactivated the WS2812 strip does work fine. It's only when I try to add the serial hardware bit into the program that it fails to work. It does compile fine so it's not that there are problems with the logic of the  code. I have SPI on Pin A0, TX on Pin C1 and RX on Pin C2. 
It says in the ws2812b_spi.jal library file, line 27, that the module should be initialised with ws2812b_async_init but I've tried that and it doesn't work - but then I didn't expect it to when there was a ws2812b_spi_init procedure which works fine.

Thanks Patrick for your response. I will look at the various programs you have posted.

Cheers

Fraser

Rob CJ

unread,
Jan 25, 2026, 11:57:07 AMJan 25
to jallist
Hi Fraser,

I see that you are using PPS mutiple times which is only allowed if the PPS1WAY is allows that. If  you look in the device file you find this:

pragma fuse_def PPS1WAY:1  0x800 {       -- PPSLOCK bit One-Way Set Enable bit
       ENABLED = 0x800                   -- The PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
       DISABLED = 0x0                    -- The PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)

So it seems that it is not possible so try combining your PPS action into 1 action to see if that solves the problem or add at the start of your program:
pragma target PPS1WAY DISABLED -- Allow multiple PPS actions

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens FraserSmith51 <fra...@cairntoul.net>
Verzonden: zondag 25 januari 2026 17:47
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] Serial Hardware and SPI not working together
 

FraserSmith51

unread,
Jan 25, 2026, 1:16:05 PMJan 25
to jallist
Thanks Rob

That is most likely the problem and will be great when I can get my serial hardware working again after too much fiddling with the code!

FraserSmith51

unread,
Jan 25, 2026, 1:30:24 PMJan 25
to jallist
Hi Rob

Yup, That was the problem. All sorted now. I have the configuration of the SPI and the Serial Hardware in two include files that are now lying between the PPS unlock and lock so I don't need the PPS1WAY pragma as I don't need to move the inputs and outputs again.

Thanks again for your assistance

Fraser

Rob CJ

unread,
Jan 25, 2026, 1:31:19 PMJan 25
to jal...@googlegroups.com
Hi Fraser,

Good to hear that it works.

Good luck with your project.

Kind regards,

Rob


Verzonden: zondag 25 januari 2026 19:30
Reply all
Reply to author
Forward
0 new messages