Posted: Wed Feb 24, 2021 2:21 pm Post subject: SPI and RGB LED tape
Hi
The last time I pointed it out, I tried.
Control of the RGB LED tape using the SPI peripheral.
Theoretically, this method should be faster than using TCB, which I showed last time, but unfortunately the engineers in the microchip made a mistake and cannot start timing with CLK2. I mean, it's generating weird pulses at least on the sample I have in the development board.
So if anyone ever needs it, here's an example.
sub vys (color()asbyte, byval delka asbyte) dim maska asbyte dim i asword dim pom asbyte dim pom1 asbyte dim m asbyte
i=0
pom1=0 disableinterrupts'Turn off interrupts to be sure for i= delka to0step-1
pom1=pom1+1
maska = &B10000000
m=8 while m >0
pom=color(pom1)
pom=maska and pom
if pom>0then
spi0_data=&B10001111 'Number of timer pulses for state H
else
spi0_data=&B11011111 'Number of timer pulses for state L
end if while spi0_intflags.7=0'waiting for byte to drop wend
spi0_intflags.7=1'flag zero
m=m-1
shift maska,right wend if pom1=3then
pom1=0 end if next i
enableInterrupts
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum