Jan Kedzierski

KSDK v2 SAI driver problem

Discussion created by Jan Kedzierski on Jun 6, 2016
Latest reply on Jul 2, 2016 by Jan Kedzierski

Dear Community,

I have following problems with SAI examples on my board (custom).

 

Configuration is:

KSDK build with online builder: SDK_2.0_MK26FN2M0xxx18

Demo runs under FreeRTOS (I copied examples code to created sound task).

Hardware: Kinetis K26, XTAL 8MHz run at 180MHz in PEE mode, codec - SGTL5000.

 

Clocks are configured as followed:

 

  CLOCK_SetSimSafeDivs();

 

  oscConfig.freq = BOARD_XTAL0_CLK_HZ;

  oscConfig.capLoad = 0U;

  oscConfig.workMode = kOSC_ModeOscLowPower;

  oscConfig.oscerConfig.enableMode = kOSC_ErClkEnable;

  CLOCK_InitOsc0(&oscConfig);

 

  CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ);

 

  g_pllConfig.enableMode = 0U;

  CLOCK_CalcPllDiv(g_xtal0Freq, BOARD_MCGOUTCLK_FREQ, &g_pllConfig.prdiv, &g_pllConfig.vdiv);

 

  CLOCK_BootToPeeMode(kMCG_OscselOsc, kMCG_PllClkSelPll0, &g_pllConfig);

  assert(kMCG_ModePEE == CLOCK_GetMode());

 

  simConfig.pllFllSel = 1U;     /* PLLFLLSEL select PLL. */

  simConfig.pllFllDiv = 0U;       /* PLLFLLSEL clock divider divisor */

  simConfig.pllFllFrac = 0U;      /* PLLFLLSEL clock divider fraction */

  simConfig.er32kSrc = 2U;        /* ERCLK32K selection, use RTC. */

  simConfig.clkdiv1 = 0x02260000U; /* CKLDIV1 = 1,  CKLDIV2 = 3,  CKLDIV3 = 3,  CKLDIV4 = 7,  */

  CLOCK_SetSimConfig(&simConfig);

 

  SystemCoreClockUpdate();

 

I've checked all three examples (boards/twrk65f180m/driver_examples/sai ) and in all cases had some problems.

 

Ex 1 & 2.  interrupt & interrupt transfer

I can not play music.h clear at 180MHz. I heard some noises and after few playing loops like this

 

while (1)

  {

  PRINTF("Play ");

  SAI_TransferSendNonBlocking(DEMO_SAI, &txHandle, &xfer);

  /* Wait until finished */

  isFinished = false;

  /* Wait until finished */

  while (isFinished != true)

  { vTaskDelay(100); }

  PRINTF("Stop ");

  vTaskDelay(200);

  }

 

it hangs. At 168MHz and lower everything runs ok for a long time.

 

Ex. 3 dma_transfer

 

Here I have the same problem with noises at coreClock >168MHz, moreover i can play sound only once

 

while (1)

  {

  PRINTF("Play ");

  isFinished = false;

  SAI_TransferSendEDMA(DEMO_SAI, &txHandle, &xfer);

  /* Wait until finished */

  while (isFinished != true)

  { vTaskDelay(100); }

PRINTF("Stop ");

  vTaskDelay(2000);

  }

 

it stopes on second isFinished loop.

What Am I doing wrong? Do I need any additional configuration?

Outcomes