I'm just putting together a list of pin resources for my product and, no surprises, I'm running out of IO.
Is it possible to use DAC0_OUT as an Digital Output? For the application, the operation does not need to be particularly fast nor high current (1mA max).
Any example code (I will be working with KSDK2) would be very much appreciated.
Thanx,
myke
Hello Myke:
Please always mention the full part number so we can provide better assistance.
Regarding DAC0_OUT, you need to check the pinout table in the corresponding Reference Manual to see if the pin has a GPIO function assigned under ALT0.
- For example the KL25 manual shows this:
Then you can configure the pin as PTE30 and use it as GPIO. It can also be used for TPM module.
- On the other hand if you see the K64 manual then you would find this:
Then you can see that the pin does not have any digital function, only analog (DAC, Comparator and ADC).
- Now if you intend to use the DAC low and high digital values conversion to emulate a digital output then I guess it is possible but not an efficient approach. Also as you mentioned pay attention not to exceed the max output load current as specified in the datasheet. Below an example for K64:
Best regards,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
HI Jorge,
Thank you for the reply - sorry about that, the part number I'm interested in is the MK22FN128VLH10
If I look at the datasheet, the DAC0_OUT pin is the same as the K64 example you quoted.
Going a bit further and looking at the KSDK2 API Reference, I see
Working as a basic DAC without the hardware buffer feature.
// ...
// Configures the DAC.
DAC_GetDefaultConfig(&dacConfigStruct);
DAC_Init(DEMO_DAC_INSTANCE, &dacConfigStruct);
DAC_SetBufferReadPointer(DEMO_DAC_INSTANCE, 0U);
// ...
DAC_SetBufferValue(DEMO_DAC_INSTANCE, 0U, dacValue);
Which should give me the capability to set DAC0_OUT to the output that is required (by calling "DAC_SETBufferValue" as needed)?
myke