For a Testproject, i want to control some SK6812 - LED (wich are WS2812 compatible).
Those require a strict timing. I use the SPI of the PIC, using a 8MHz Clock (using the PLL for 16MHz system clock). In theory, it is possible to achive the WS2812 timing.
I got a small SPI Problem there:
I can achive the timing only, if i use the SPI in 32bit-Mode. In 8bit or 16 bit-mode, i get constant "pauses" between two transfers.
See attached picture. For the picture, i am constantly writing 8bit 0xAA. Channel1 is data, Channel2 is clock.
The main loop consists of
[code] LATBbits.LATB2 = 1;
SPI2_RXTX_EBUF_8bit(0xAA);
LATBbits.LATB2 = 0;[/code]
Thats all. I use the Port B2 for timing tests.My SPISettomgs:
[code] //init SPI
SPI2CON = SPI2CON2 = 0;
SPI2CONbits.MODE16 = 0; //1 for 16bit mode
SPI2CONbits.MODE32 = 0; //1 for 32bit mode
SPI2CONbits.CKE = 0;
SPI2CONbits.CKP = 1;
SPI2CONbits.ENHBUF = 1;
set->Baudrate = SPI2_Setbaud(set->Baudrate, pCLK);
SPI2CONbits.MSTEN = 1;
SPI2STATbits.SPIROV = 0;
SPI2CONbits.ON = 1;[/code]
I use the following for transfer:
[code]inline uint8_t SPI2_RXTX_EBUF_8bit(uint8_t data){
while(SPI2STATbits.SPITBF);
SPI2BUF = data;
return SPI2BUF;
}[/code]
Tools:- XC32 v 1.4
- MPLABX 3.51
- PICkit 3 (also for power)
The SPI-Code works fine on a PIC32MX470 and PIC32MX250. I dont remember any pauses from previous projects with PIC32 MX devices.
What am I doing wrong here?
Thanks for any help in advance!