Writing code of KL27128 48 QFN.
The SDK for KL27 does not support the DAC12. There is no API documentation. The registers are not defined in MKL27Z4.h.
What happened?
Solved! Go to Solution.
I found out why the DONE bit is cleared. The SDK does it in DMA_HandleIRQ. This is an unfortunate consequence of using SDKs.
All is good. I got it running. No more help needed.
I'm using correct SDK (KL27Z256).
The issue is that it's not mentioned at all in the documentation.
How do you set the ERQ bit in DMA_DCRx? I don't see how SDK support this.
I am using a PWM counter TPM1 Ch0 to drive the DMA to transfer 16-bit values from memory to the DAC.
When the interrupt occurs, the BCR is zero (as it should be), but the DONE bit is never set.
Do you have any idea why this is? I need to run this in a constant loop. It's an audio application where sound data in SRAM is continuously sent to the DAC at a fixed sample rate (22KHz). I've done this before using the K22F and KL25 with great success (I used Processor Expert to initialize the peripherals).
Attached is my code.
Brad
I found out why the DONE bit is cleared. The SDK does it in DMA_HandleIRQ. This is an unfortunate consequence of using SDKs.
All is good. I got it running. No more help needed.
Also, I get hard faults anytime I try to access the DAC registers.
For example,
#define DAC0_C0 (*(uint8_t volatile * )(DAC0_BASE + 0x21))
uint8_t k;
k= DAC0_C0; //<--causes a hard fault!
I have no problem using this method to read and write to GPIOC. It seems to be an issue with the DAC0. I get errors even by writing to DAC0_C0 in the debugger (using Keil MDK).
It turns out that the DAC clock is not set in SIM_SCGC6 (bit 31). Once set, it seems to work.
Neither the pin or clock configuration tools do this.
You need to support the DAC in your SDK and need to release the peripheral configuration tool ASAP!
Hello,
- When download KSDK for KL27128 , please choose the exactly device :
it includes the API for dac:
- About the peripheral configuration tool, it is now in field trail stage .
Hope it helps
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------