MKM34 Clock Intialization

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MKM34 Clock Intialization

1,192件の閲覧回数
dhruvonline
Contributor III

Hi All,

I have designed a custom board with MKM device. I have to use external 32KHz Oscillator for RTC and System Clock. I am unable to run the ADC and UART with External 32.768 KHz Clock. Could someone please suggest the configuration and initialization sequence for this issue. 

I am able to run the peripherals with Internal Clock & when I enable the external Clock Macro. The program is not running. I have connected the 32.768 KHz Xtal on XTAL32 & EXTAL32.

Please suggest the solution to resolve this issue. Here I am giving the initialization sequence with the external clock source.

SIM_SelClkout (CLKOUT_SRC2);
PORT_Init (PORTF,PORT_MODULE_ALT3_MODE,PIN7);

/* clock mode 1:1:1, 24MHz */
SIM_SetClkMode (SYSCLK_MODE0);
SIM_SetClkDiv (SYSCLK_DIV1);
FLL_Init (FLL_MODULE_FEE_24MHZ_CONFIG);

/* UART1 init 9600bd */
PORT_Init (PORTI, PORT_MODULE_ALT2_MODE, PIN0|PIN1);
UART_Init (UART1, UART_MODULE_INTRMODE_CONFIG(9600,24e6));

Regards,

Druv

ラベル(1)
0 件の賞賛
10 返答(返信)

800件の閲覧回数
MarMi
NXP Employee
NXP Employee

Hi Druv,

I just run uart_test example on TWR-KM34Z75M and it works just fine. What device part number are you using? 

/* uart_test example */
#include "drivers.h"
char c;
void main (void)
{
 /* enable clocks to all on chip peripherals */
 SIM_Init (SIM_MODULE_ALL_PERIPH_ON_CONFIG);
 /* route core clock to PTF7 for monitoring */
 SIM_SelClkout (CLKOUT_SRC1);
 PORT_Init (PORTF,PORT_MODULE_ALT3_MODE,PIN7);
 /* clock mode 1:1:1, 24MHz */
 SIM_SetClkMode (SYSCLK_MODE0);
 SIM_SetClkDiv (SYSCLK_DIV1);
 FLL_Init (FLL_MODULE_FEE_24MHZ_CONFIG);
 /* UART1 init 9600bd */
 PORT_Init (PORTI, PORT_MODULE_ALT2_MODE, PIN6|PIN7);
 UART_Init (UART2, UART_MODULE_POLLMODE_CONFIG(9600,24e6));
 UART_PutStr (UART2,"\n\rCharacters will be echoed on the screen:\n");
 while(1) {
  /* read and echo character */
  while (!UART_RxFull(UART2));
  c = UART_GetChar (UART2);
  while (!UART_TxIdle(UART2));
  UART_PutChar (UART2,c);
 }
}

Kind regards,
Martin M.
0 件の賞賛

800件の閲覧回数
dhruvonline
Contributor III

Hi Martin,

This is the part number for the device used. MKM33Z128ACLH5. I have tried above code on two custom boards. But no success.

Regards 

Druv

0 件の賞賛

800件の閲覧回数
MarMi
NXP Employee
NXP Employee

Hi Druv,

my example was tested on TWR-KM34Z75 and hence UART pin setting to respective pins.

Can you route core clock to CLKOUT pin and see whether right frequency is generated by FLL?

Keep in mind that some UARTs are clocked by system and some by bus clock:

 

UART0 UART1 UART2UART3
Bus clockSystem clockBus clockSystem clock

Kind regards,

Martin M.

0 件の賞賛

800件の閲覧回数
dhruvonline
Contributor III

Hi Martin,

Below is the code for my test program.

#include "drivers.h"
char c;
void main (void)
{

SIM_Init (SIM_MODULE_ALL_PERIPH_ON_CONFIG);

/* route core clock to PTF7 */
SIM_SelClkout (CLKOUT_SRC1);

PORT_Init (PORTF,PORT_MODULE_ALT3_MODE,PIN7);

/* clock mode 1:1:1, 24MHz */
SIM_SetClkMode (SYSCLK_MODE0);
SIM_SetClkDiv (SYSCLK_DIV1);
FLL_Init (FLL_MODULE_FEE_24MHZ_CONFIG);

/* UART3 init 9600bd */
PORT_Init (PORTC, PORT_MODULE_ALT2_MODE, PIN2|PIN3);
UART_Init (UART3, UART_MODULE_POLLMODE_CONFIG(9600,24e6));

UART_PutStr (UART3,"\n\rCharacters will be echoed on the screen:\n");
while(1) {
  /* read and echo character */
  while (!UART_RxFull(UART3));
  c = UART_GetChar (UART3);
  while (!UART_TxIdle(UART3));
  UART_PutChar (UART3,c);
}
}

Regards,

Druv

0 件の賞賛

800件の閲覧回数
MarMi
NXP Employee
NXP Employee

Hi Druv,

I don't see any issue in your code. You said with internal clock source UART works, right?

Therefore, measure system clock frequency on pin. You can either use CLKOUT (PTF7) or any XBAR output pin to route clock out. Use SelClkout(), XBAR_Path() and PORT_Init() macros for that purpose.

Martin M.

0 件の賞賛

800件の閲覧回数
dhruvonline
Contributor III

Hi Martin,

I have configured the CLKOUT (PTF7) as the clock out functionality. We are not getting any output on that pin. Surprisingly we are not getting any crystal oscillations across crystal pins also. Could you please suggest the solution.

Regards,

Dhruv

0 件の賞賛

800件の閲覧回数
MarMi
NXP Employee
NXP Employee

Hi Druv,

make sure you supply also VBAT pin. 

pastedImage_2.png

Kind regards,

Martin M.

800件の閲覧回数
dhruvonline
Contributor III

Hi Martin, 

I have replaced the crystal. Now the issue is cleared. 

Regards,

Druv

0 件の賞賛

800件の閲覧回数
dhruvonline
Contributor III

Hi Martin,

I have tried to run the irtc_test example. But this example is also not running on the custom board. I have connected the external 32 .768 KHx clock also same as in the MKM34 Tower board.

What is the issue?

 

I will check the Clock out also. 

Thanks,

Druv

0 件の賞賛

800件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Druv,

Have you try to test the example using KDS?

KM128SWDRV_R4_1_6.png

I test the uart_test example on TWR-KM34Z50MV3 board using KDS and IAR.

It doesn't work when using IAR.

I download the KM128SWDRV_R4_1_6 from Kinetis M bare-metal drivers and software examples released - REV 4.1.6.

Best Regards,

Robin

 

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

0 件の賞賛