How should i configure MKM33 AFE?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How should i configure MKM33 AFE?

793 Views
davidmartínezag
Contributor I

Hi!!!

Currently i am working using a MKM33. I try to configure the AFE but i don't get that works. In my projects the main configuration for all is:

SIM_Init  (SIM_MODULE_ALL_PERIPH_ON_CONFIG);
  

    /* clock mode 1:1:1, 24MHz                                              */

    SIM_SetClkMode (SYSCLK_MODE0);

    SIM_SetClkDiv  (SYSCLK_DIV1);

  

    FLL_Init  (FLL_MODULE_FEI_24MHZ_CONFIG);

From this configuration I have to do the rest of peripherals configuration. if someone could help me I will be very grateful.

Thanks for advance.

David

0 Kudos
2 Replies

528 Views
isaacavila
NXP Employee
NXP Employee

Hi David,

According to what i am seeing in your code, your are using KM128SWDRV_R4_0_0 software version for KM family. If so, there is a useful example that shows all the configuration for AFE peripheral for polling and interrupt mode and low power as well.  (<FREESCALE_PATH>\KM128SWDRV_R4_0_0\build\cw_10_6\projects)

In this example, KM is configured as follows:

void main(void)

{

  /* initialize SIM module                                                    */

  SIM_Init  (SIM_MODULE_ALL_PERIPH_ON_CONFIG);

  /* clock mode 2:1:1, 48MHz                                                  */

  SIM_SetClkMode (SYSCLK_MODE1);

  SIM_SetClkDiv  (SYSCLK_DIV1);

  FLL_Init  (FLL_MODULE_FEE_48MHZ_CONFIG);

  /* sets 32 KHz RTC Oscillator as the source of the PLL and enable PLL       */

  PLL_Enable (PLL32KREF_SRC1);

  /* VREF module must be initialized after SIM module                         */

  VREF_Init (VREF_MODULE_CHOP_ON_1V75_0V4_HPWR_CONFIG,

             VREF_SWITCH_S1_L_S2_L_S3_L_BUFF_ON);

  /* AFE_CH1 init                                                             */

  SIM_SelAfePllClk (SIM_MCG_PLL_CLK);

  AFE_ChInit (CH0, AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR64), 0, PRI_LVL0, NULL);

  AFE_Init   (AFE_MODULE_RJFORMAT_CONFIG(AFE_PLL_CLK, AFE_DIV2, 12288000));

  /* initialize UART and FreeMASTER                                           */

  PORT_Init (PORTI, PORT_MODULE_ALT2_MODE, PIN0|PIN1);

  UART_Init (UART1, UART_MODULE_POLLMODE_CONFIG(38400,48e6));

  FMSTR_Init();

  diagnostic_setup ();

  /* trigger AFE conversions                                                  */

  AFE_SwTrigger (CH0);

  /* main loop                                                                */

  while (1)

  {

    if (AFE_ChReady(CH0))

    {

      result = AFE_ChRead (CH0);

      FMSTR_Recorder ();

    }

    FMSTR_Poll ();

  }

}

In this configuration, FreeMaster is used so you can ommit FMSTR_ functions.

I hope this can help you.

If you have any specific doubt please let me know it.

Regards,

Isaac

----------------------------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------------------------

0 Kudos

528 Views
davidmartínezag
Contributor I

Thanks Isaacavila!!!

Are you from Spain?

Anyway i used that configuration. The isuue is that my board doesn't external clock, i am using the internal clock of the microcontroller, this means that FLL is busy for the general configuration, then i can't use it. My idea is use the PLL for the AFE but I can't do it.

thanks for advance!!!

0 Kudos