KL03: PE code generated for high level SDK LPUART component not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

KL03: PE code generated for high level SDK LPUART component not working

1,328 次查看
rolandzitzke
Contributor II

Hi, I am using PE to create a simple application for A KL03 controller which uses the UART. PE offers a high level LPUART component (the phone symbol) and it generates code which compiles without errors. However, When trying to transmit something the code appears to wait for ever to complete transmission. It looks like the ISR which handles this is never invoked. Besides a plain UART, PE also offers a debug console in the utilities category for this KL03 controller. When I try to simply use this high-level component the code gets stuck during component initialization attempting to call the standard library "setvbuf" function. Has anyone successfully used the high level SDK component or the debug console component for KL03?

TIA, Roland

1 回复

693 次查看
marek_neuzil
NXP Employee
NXP Employee

Hi Roland,

I suppose you are using fsl_lpuart component from SDK. There is known issue - the LPUART device clock source  selection in SIM device is not done by the fsl_lpuart component (the default value is "clock source disabled"; see the after reset value of LPUART0SRC bits in SIM_SOPT2 register). This defect has been fixed in the upcoming SDK 1.1 release (it will be publushed soon).

You can use the following workaround:

Disable autoinitialization in the Component Inspector of the fsl_uart component in the project:

fsl_lpuart_settings_on_KL03.png
And use the following initialization code of the fsl_lpuart component in your application (it must be used after PE_low_level_init() call in the main() function). See example below:

int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  const uint8_t test_data[10] = "123456789";
  uint32_t test_data_size = 9;
  /* definition of LPUART state structure */
  lpuart_state_t fsl_lpuartCom1_state;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

/* Selects the clock source for the LPUART0 transmit and receive clock.
  *
  * Values:
  * - 00 - Clock disabled
  * - 01 - IRC48M clock
  * - 10 - OSCERCLK clock
  * - 11 - MCGIRCLK clock
  */
  CLOCK_SYS_SetSource(kClockLpuart0Src, 0x3 /* LPUART0SRC  - MCGIRCLK = 0x3 */);
  /* fsl_lpuart component initialization; lpuartCom1_InitConfig0 structure is generated by the fsl_lpuart component */
  LPUART_DRV_Init(FSL_LPUARTCOM1,&fsl_lpuartCom1_state,&lpuartCom1_InitConfig0);
  /* send test data in a loop */
  for(;;) {
      LPUART_DRV_SendData(FSL_LPUARTCOM1, test_data, test_data_size);
  }

. . .

The clock source is selected in the SIM device (LPUART0SRC bits in the SIM_SOPT2 register) and the baudrate is correctly initialized by the LPUART_DRV_Init() method.

Best Regards,

Marek Neuzil