Hello, are there anyone using COP and internal ADCs on MKL15?

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

Hello, are there anyone using COP and internal ADCs on MKL15?

1,290 Views
RuiFaria
Contributor III

Hello,

Are there anyone using COP and internal ADCs on MKL15?

Best Regards,

Rui Faria

Tags (3)
0 Kudos
8 Replies

1,059 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please check attached KL series COP validation code.

And you could find KL26 ADC example code at KL26 sample software [FRDM_KL26Zdemo] project, major at <adc_test.c>. (KL15 using the same ADC module with KL26)

The KL26 sample code could be downloaded here.


Have a great day,
best regards,

Ma Hui

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

0 Kudos

1,059 Views
RuiFaria
Contributor III

Hi,

Thank you for your attention and help.

Could you help me to know how to print "unsigned long long" and "float" types?

Best regards,

Rui Faria

0 Kudos

1,059 Views
bobpaddock
Senior Contributor III

#include <inttypes.h> to get the format specifiers for your compiler.

Explained here: Formatted output when using C99 data types « Stack Overflow

0 Kudos

1,059 Views
RuiFaria
Contributor III

I tried this:

char SerialBuffer[13];

int Trash = sprintf(SerialBuffer, "%llu", Value);

or

int Trash = sprintf(SerialBuffer, "%" PRIu64, Value);

In the two situtions prints "lu"

0 Kudos

1,059 Views
RuiFaria
Contributor III

Hi,

i were checking the <adc_test.c> example but it doesn't seem right.

uint16 adc_read(uint8 channel)

{

 

   ADC0_SC1A = !AIEN_ON | DIFF_SINGLE | ADC_SC1_ADCH(channel) ;     // start conversion

   while((ADC0_SC1A & ADC_SC1_COCO_MASK)!= 0){};

   return ADC0_RA;

}


Page 453 of KL15P80M48SFORM.pdf

7 COCO

Conversion Complete Flag

Field Description

This is a read-only field that is set each time a conversion is completed when the compare function is

disabled, or SC2[ACFE]=0 and the hardware average function is disabled, or SC3[AVGE]=0. When the

compare function is enabled, or SC2[ACFE]=1, COCO is set upon completion of a conversion only if the

compare result is true. When the hardware average function is enabled, or SC3[AVGE]=1, COCO is set

upon completion of the selected number of conversions (determined by AVGS). COCO in SC1A is also set

at the completion of a calibration sequence. COCO is cleared when the respective SC1n register is written

or when the respective Rn register is read.

0 Conversion is not completed.

1 Conversion is completed.


So we start conversion and wait while Conversion is completed...


0 Kudos

1,059 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

For the ADC module operation, customer could enable ADC interrupt mode.

When ADC module finish the conversion and will generate an interrupt, in interrupt service routine, the ADC conversion result could be read out.

The FRDM_KL26Z board ADC demo is using the interrupt mode, customer could download related code here.

Wish it helps.


Have a great day,
best regards,

Ma Hui

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

0 Kudos

1,059 Views
RuiFaria
Contributor III

hi,

I tested ADC code in FRDM_KL25Z board and seems to be working well, but not so good in my custom board with MKL15. The values are always in overflow state (0xFFFF) and i don't understand why.

I tried to read TempSensor, ADC0_SE8/PTB0 and ADC0_SE13/PTB3 inputs using Generated Code by Processor Expert.

Thanks for your attention.

Best Regards,

Rui Faria

0 Kudos

1,059 Views
RuiFaria
Contributor III

hi,

There are any problem in using VREFH equal to VDDA 3V3? it is the only difference between boards.

0 Kudos