MCU SDK MKE04Z

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

MCU SDK MKE04Z

927 Views
pauvilanova
Contributor III

Hi,

I'm having trouble programming peripherals in the MKE04Z8VTG4 on MCUxpresso IDE. For instance there aren't any type of driver example on the freedom FRDM-KE04Z sdk builder, and moreover I cannot build a debug code because MKE04Z just has 8kb of flash and  building a out of the box hello world code in MCUxpresso already needs 10kb.

It's difficult to find any information related to sdk drivers/kinetis with MCUxpresso, is it because xpresso is relatively new? or is it that no one is working with it¿

I'm trying to code a simple adc in channel 1 of my MCU but it does not work. Enabling analog input at the begining just crashes my code. First with the sdk drivers I was testing with different configurations but the results were the same:

    ADC_EnableAnalogInput(ADC, kFTM_Chnl1Flag, true);

    adc_config_t adcConfigStruct;
    ADC_GetDefaultConfig(&adcConfigStruct);
    // Config ADC
    //adcConfigStruct.clockSource = kADC_ClockSourceAlt3;
    //adcConfigStruct.ResolutionMode = kADC_Resolution10BitMode;
    //adcConfigStruct.clockDivider = kADC_ClockDivider2;

    // Init ADC
    ADC_Init(base, &adcConfigStruct);

    // Conversion trigger selection.
    ADC_EnableHardwareTrigger(base, false);

    EnableIRQ(ADC_IRQn);

And then I tried with bits and the result is the same.

ADC->APCTL1 = ADC_APCTL1_ADPC(1);
    ADC->SC3 = ADC_SC3_MODE(0);
    ADC->SC2 = 0x00;
    ADC->SC1 = ADC_SC1_AIEN_MASK | ADC_SC1_ADCH(1);

If I don't enable the analog I/O the code runs and the interrupt works but the adc conversion does not give . So if anyone can give me a hint of what I'm supposed to do that would be great.

PD: I know to make an interrupt I have to do the following:

ADC_SetChannelConfig(ADC, &adcChannelConfigStruct);
where adcChannelConfigStruct contains: the channel I want to convert and the enable interrupt on conversion bit. The main problem is that my code gets stuck in the initialitzation of the ADC itself.

Thanks

Tags (1)
0 Kudos
2 Replies

690 Views
lpcxpresso_supp
NXP Employee
NXP Employee

One "feature" of the MCUXpresso SDK codebase is that it contains a number of assert() checks to ensure that parameters are valid. When doing debug builds with MCUXpresso IDE, these assert() statements will cause a string containing the full filename (including the path) into your code. This can have a noticeable affect on the overall code size for your project when building the Debug build configuration - and with a small flash device can actually prevent the project building successfully.

However it is very easy to disable these assert() statements. To do this, go to:

  • Project -> Properties -> C/C++ Build -> Settings -> MCU C Compiler -> Preprocessor

and add the define NDEBUG. Then try cleaning and rebuilding your project.

Another simple change to reduce code size is, if you are not going to use printf/semihosting for output (which on an 8KB flash device, you probably don't want to) is to change the C library variant that your project is linked against.

The simplest way to do this is to highlight your project in Project Explorer, then use:

  • QuickStart Panel -> Miscellaneous -> Quick Settings -> Set library/header type -> Redlib(none)

[See chapter 15, "C/C++ Library Support" in the MCUXpresso IDE v10.2 User Guide for more details on this]

Regards,

MCUXpresso IDE Support

0 Kudos

690 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Pau,

The default SDK demo code includes debug console initialization code and io print function. These part of codes are very memory consuming. So for this kind of limited memory chip, I suggest you remove debug console functions:

pastedImage_1.png

the SDK demo code includes ADC demo code. But from my testing the SDK importer for FRDM-KE04Z has problem. I contacted development team. I will let you know if it get fixed.


Have a great day,
TIC

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

0 Kudos