Operate DAC in mkl27Z644, ( LQFP64)

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

Operate DAC in mkl27Z644, ( LQFP64)

800 Views
grinberg_zvika
Contributor I

Operate DAC in mkl27Z644, ( LQFP64)

Hi,

I have to operate PTE30 as DAC0_OUT, but without any success.

Few general questions:

1) Did I need to operate the comparator ? what the input channle I configure as "kCmpInputChnDac"

2) The filter Mode ? 

3) Did I need to configure PTE30 to an alternative ? 

4) I have also try to set the registers manually Via the IAR debugger, and still Noting changed.

 

Please Advise.

My Code is :

// Configuration for cmp
cmp_state_t cmpState;
cmp_comparator_config_t cmpUserConfig;
cmp_sample_filter_config_t cmpSampleFilterConfig;
cmp_dac_config_t cmpDacConfig;

// Disable falling interrupt
// Init the CMP comparator.
CMP_DRV_StructInitUserConfigDefault(&cmpUserConfig, (cmp_chn_mux_mode_t)BOARD_CMP_CHANNEL, kCmpInputChnDac);
cmpUserConfig.risingIntEnable = false;
cmpUserConfig.fallingIntEnable = false;
CMP_DRV_Init(BOARD_CMP_INSTANCE, &cmpState, &cmpUserConfig);

// Configure the internal DAC when in used.
cmpDacConfig.dacEnable = true;
cmpDacConfig.dacValue = 32; // 0U - 63U
cmpDacConfig.refVoltSrcMode = kCmpDacRefVoltSrcOf2;
CMP_DRV_ConfigDacChn(BOARD_CMP_INSTANCE, &cmpDacConfig);

// Configure the Sample/Filter Mode.
cmpSampleFilterConfig.workMode = kCmpContinuousMode;
CMP_DRV_ConfigSampleFilter(BOARD_CMP_INSTANCE, &cmpSampleFilterConfig);

// Start the CMP function.
CMP_DRV_Start(BOARD_CMP_INSTANCE);

Thanks,

Zvk.gg

0 Kudos
4 Replies

707 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

Based on your code, I understand that you are following the example for the CMP in the SDK. However you will not see what the DAC is doing in this case, because the module used in this example is an internal DAC signal. 

I recommend that you check chapter 25 of the reference manual on how to configure and use the 12-bit DAC, that can be seen on pin PTE30. 

There is an example for the KL25 that you can use as a reference in the SDK for FRDM-KL25.

Best Regards,

Sabina

0 Kudos

707 Views
grinberg_zvika
Contributor I

Hi, 

1)The referance for the manual  chapter 25 , Not relevance to my board "FRDM-KL27Z" that contain MKL27Z644

"KL27 Sub-Family Reference Manual Supports: MKL27Z128VFM4, MKL27Z256VFM4, MKL27Z128VFT4, MKL27Z256VFT4, MKL27Z128VMP4, MKL27Z256VMP4, MKL27Z128VLH4, MKL27Z256VLH4"

2) the board feature in the SDK MKL27Z644_features.h not contain the DAC as KL25 

/* @brief DAC availability on the SoC. */
#define FSL_FEATURE_SOC_DAC_COUNT (0)

3) The Lib for this platform (C:\Freescale\KSDK_1.3.0\lib\ksdk_platform_lib\iar\KL27Z644) NOT!!!! contains the DAC API in the example you reference too

Building configuration: ksdk_platform_lib - Debug
Updating build tree...

147 file(s) deleted.
Updating build tree...
fsl_adc16_common.c
fsl_clock_manager.c
fsl_clock_manager_common.c
fsl_adc16_driver.c
fsl_adc16_hal.c
fsl_clock_MKL27Z644.c
fsl_cmp_common.c
fsl_cop_common.c
fsl_cmp_hal.c
fsl_cmp_driver.c
fsl_cop_driver.c
fsl_cop_hal.c
fsl_crc_common.c
fsl_crc_hal.c
fsl_dma_common.c
fsl_crc_driver.c
fsl_dma_hal.c
fsl_dma_driver.c
fsl_dmamux_hal.c
fsl_flexio_common.c
fsl_flexio_hal.c
fsl_flexio_i2c_hal.c
fsl_flexio_driver.c
fsl_flexio_i2s_hal.c
fsl_flexio_i2s_driver.c
fsl_flexio_i2c_master_driver.c
fsl_flexio_spi_hal.c
fsl_flexio_spi_driver.c
fsl_flexio_uart_dma_driver.c
fsl_flexio_uart_driver.c
fsl_flexio_uart_hal.c
fsl_gpio_common.c
fsl_gpio_hal.c
fsl_gpio_driver.c
fsl_hwtimer.c
fsl_i2c_common.c
fsl_hwtimer_systick.c
fsl_hwtimer_pit.c
fsl_i2c_hal.c
fsl_i2c_shared_function.c
fsl_i2c_master_driver.c
fsl_interrupt_manager.c
fsl_llwu_hal.c
fsl_i2c_slave_driver.c
fsl_lptmr_common.c
fsl_lpuart_common.c
fsl_lptmr_driver.c
fsl_lptmr_hal.c
fsl_lpuart_dma_driver.c
fsl_lpuart_hal.c
fsl_mcglite_hal.c
fsl_lpuart_driver.c
fsl_mcglite_hal_modes.c
fsl_os_abstraction_bm.c
fsl_pit_common.c
fsl_osc_hal.c
fsl_pit_hal.c
fsl_port_hal.c
fsl_pit_driver.c
fsl_rcm_hal.c
fsl_rtc_common.c
fsl_power_manager.c
fsl_rtc_hal.c
fsl_sim_hal_MKL27Z644.c
fsl_smc_hal.c
fsl_rtc_driver.c
fsl_spi_common.c
fsl_spi_dma_shared_function.c
fsl_spi_hal.c
fsl_spi_dma_master_driver.c
fsl_spi_dma_slave_driver.c
fsl_spi_master_driver.c
fsl_spi_shared_function.c
fsl_tpm_common.c
fsl_spi_slave_driver.c
fsl_uart_common.c
fsl_tpm_hal.c
fsl_tpm_driver.c
fsl_uart_dma_driver.c
fsl_vref_common.c
fsl_uart_hal.c
fsl_vref_driver.c
fsl_vref_hal.c
fsl_uart_driver.c
Building library

Total number of errors: 0
Total number of warnings: 0

4) The FRDM-KL27Z I using not route the output PTE30 to any header 

Please Help, there is a missing puzzle in the picture that avoiding to operate the DAC

Thanks,

Zvk.gg

0 Kudos

707 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

In the case you are using MKL2764, then please refer to the CMP example in the SDK.

pastedImage_1.png

If you are using IAR, you will find it available in the SDK that can be downloaded in the MCUXpresso website.

It does not have a DAC driver like MKL25Z(this has a DAC module).

The 6-bit DAC from a comparator is available as an on-chip internal signal only and is not available externally to a pin.

Please try to run the examples provided in the SDK, can you confirm if they work as expected?

Best Regards,

Sabina

0 Kudos

707 Views
grinberg_zvika
Contributor I

Sabina, 

First, thanks for your answer,

I have given it a try but is not work,

We buy external DAC MCP47, one channel.

the time and effort are Not meet our Project timeline.

Thanks,

Zvika

0 Kudos