Loading dot correction values into TLC5940

I believe I have my head around how to do this and my function is below.

Once you load the values is there any convenient way in code to check if the values have gone in OK?

void loadDotCorrection()
{
  int nLength =  NUM_TLC5940 * 16, nI = 0, nJ = 0;
  byte bNewVal = 0, arrayShiftedDCVals[nLength];
  
  copyByteArray(arrayDCVals, arrayShiftedDCVals, nLength);

#ifdef DEBUG
  outputByteArray(arrayShiftedDCVals, nLength);
#endif
 
  // Bit shift all the values 2 bits to the left so that the most significant bit of all the 6 bit dot correction values is also the most signficant bit of all the 8 bit values in the array.
  for (nI = 0; nI < nLength; nI += 3)
  {
    if ((nI + 3) < nLength)
    {
      // Value nI can take the two most signficant bits of the next value.
      arrayShiftedDCVals[nI] = arrayShiftedDCVals[nI] << 2; // 00111111(63) -> 11111100
      bNewVal = arrayShiftedDCVals[nI + 1] >> 4; // 00111111(63) -> 00000011
      arrayShiftedDCVals[nI] |= bNewVal; // The two most signficant bits of the next value loaded into the least two signficant bits of the current value, 11111100 & 00111111 -> 11111100 | 00000011 -> 11111111 & 00001111
      arrayShiftedDCVals[nI + 1] = arrayShiftedDCVals[nI + 1] << 4; // 00111111 ->11110000
      
      // Value nI + 1  can now take the 4 most signficant bits of value nI + 2.
      bNewVal = arrayShiftedDCVals[nI + 2] >> 2; // 00111111(63) -> 00001111
      arrayShiftedDCVals[nI + 1] |= bNewVal; // The four most signficant bits of the next value loaded into the least four signficant bits of the current value, 11110000 & 00111111 -> 11110000 | 00001111 -> 11111111 & 00000011
      arrayShiftedDCVals[nI + 2] = arrayShiftedDCVals[nI + 2] << 6; // 00111111 ->11000000
      
      // Value nI + 2  can now take the 6 most signficant bits of value nI + 3.
      arrayShiftedDCVals[nI + 2] |= arrayShiftedDCVals[nI + 3]; // The four most signficant bits of the next value loaded into the least four signficant bits of the current value, 11110000 & 00111111 -> 11110000 | 00001111 -> 11111111 & 00000011
 
      // Move all the values up by one element.
      for (nJ = nI + 3; nJ < nLength; nJ++)
      {
        if (nJ < (nLength - 1))
          arrayShiftedDCVals[nJ] = arrayShiftedDCVals[nJ + 1];
      }
   }
  }
/* 
    Dot correction values are only 6 bits.
    So, if there are 16 ports, then you need 6 x 16 = 96 bits = 12 BYTEs for dot correction and 12 x 16 = 192 = 12 UINTs
    TLC5940    PORTS    TOTAL BYTES REQUIRED(NUM_VALS)
    ---------------------------------------------------------------
    1          16       16 x 6 = 96 bits / 8 bits per byte = 12
    2          32       32 x 6 = 192 bits / 8 bits per byte = 24
    3          48       48 x 6 = 288 bits / 8 bits per byte = 36
    
    So the bytes in arrayShiftedDCVals beyond NUM_VALS can be set to zero because those bytes wont be transmitted into the TLC5940
*/
  for (nJ = NUM_VALS; nJ < nLength; nJ++)
  {
    arrayShiftedDCVals[nJ] = 0;
  }
#ifdef DEBUG
  outputByteArray(arrayShiftedDCVals, nLength);
#endif
  // Making the VPRG pin on the TLC5940 high allows you to pass the 6 bit dot correction values into the shift registers.
  digitalWriteFast(VPRG, HIGH);
  SPI.begin();
  for (nJ = 0; nJ < NUM_VALS; nJ++)
    SPI.transfer(arrayShiftedDCVals[nJ]);
  
  // Making the XLAT pin high causes the values in the TLC5940 shift registers to be transfered to its dot correction registers.
  digitalWriteFast(XLAT, HIGH);
  
  // Making the XLAT pin low causes  the TLC5940 to lock its dot correction registers.
  digitalWriteFast(XLAT, LOW);
  
  // Making the VPRG pin on the TLC5940 low allows you to pass the 12 bit grey scale values into the shift registers.
  digitalWriteFast(VPRG, LOW);
}

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the # button above the posting area.