PIC32MMGPL028 - Pauses in SPI transfer in 8bit and 16bit mode

You can post your problem related to PIC Microcontroller Projects here. We will try our best to help you out.
Post Reply
McDonough
Posts: 6
Joined: Sat Feb 18, 2017 5:38 am

PIC32MMGPL028 - Pauses in SPI transfer in 8bit and 16bit mode

Post by McDonough » Mon Mar 06, 2017 10:50 am

i am currently evaluating some PIC32MM devices.
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: Select all

  LATBbits.LATB2 = 1;
        SPI2_RXTX_EBUF_8bit(0xAA);
        LATBbits.LATB2 = 0;
Thats all. I use the Port B2 for timing tests.

My SPISettomgs:

Code: Select all

 //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;
I use the following for transfer:

Code: Select all

inline uint8_t SPI2_RXTX_EBUF_8bit(uint8_t data){
    while(SPI2STATbits.SPITBF);
    SPI2BUF = data;
    return SPI2BUF;
}
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!

Post Reply