code size read temperature CPU

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

code size read temperature CPU

Jump to solution
2,145 Views
nguyennhatminh
Contributor IV

Hi pro,

 

I followed the App Note AN3031 to read the temperature of MCU KL05Z .

 

and using fixed-point method.

 

After building the code size about 35kbytes . But as the App Note the code size for Fixed-point is about 698 bytes.

 

Please see attached file and help me explain why this happened,

 

and The temperature is about 37C, is it correct ?

 

Thank you,

Minh.

Original Attachment has been moved to: Read-MCU_temp.rar

Labels (1)
0 Kudos
1 Solution
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

      Thank you for your new version datasheet.

      I help you do a project, you can refer to it, please find the project from the attachment.

    I test it based on our FRDM_KL05, my test result print like following:

pastedImage_0.png

  Wish it helps you!

If you still have quesiton, please contact me!


Have a great day,
(Jingjing)

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

View solution in original post

0 Kudos
11 Replies
1,298 Views
egoodii
Senior Contributor III

With a 'little care' in scaled integers (millivolt counts and milli-Celsius results) integers will provide a very satisfactory result.  You might look at:

Re: K70 Temperature reading - Slopes

After converting the ADC measurement to 'millivolts' (and given 1.715mV/C slope and 719mV calibration at 25,000mC), the equation to mill-Celsius is just:

(int32_t)TEMPx1000=25000-( Vtemp(mV)-Vtemp25(719mV) )*583.

Your constants (above) from the KL datasheet would be a little different -- 716mv for the 25C reference, and a slope of 1.62mV/C makes my reciprocal 'multiplier' 617C/V instead of 583.

0 Kudos
1,298 Views
nguyennhatminh
Contributor IV

Hello Jingjing Zhou,

Thank you very much for your help. Please attach the project, I think you forgot.

How do you get the value on the green screen like this https___community.freescale.com_servlet_JiveServlet_showImage_2-413873-12714_pastedImage_0.png ?

As I saw , The Band gap value is almost same .  I'm in VietNam so the weather very hot now 37, so the chip around 37 C,

I think  you are in China . (I used to live 1 year in Shenzhen.) so the weather is not too hot , is that right ?

Minh

0 Kudos
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

    Didn't you see my attachment? I still  can see it.

pastedImage_0.png

please get it from the last reply I give you.

If your weather is very hot 37C, of course your chip 37 C is right, you project is correct.

Actually, your calculation is the same with me!

If you still have quesition, please let me know!

Best regards,

Jingjing

0 Kudos
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Nguyen Nhat Minh,

      Thank you for your question in our community!

      1: About the code size

        Could you tell me how did you check your code size is about 35Kbytes?

        In the AN3031, I think the code size is just the code size of Fixed-point calculations,it is not the size of whole project, because your code is generated from PE, it must be larger.

      2: About your code

        I think your temperation 37 C is not normal, so I Check your code, it has some problems.

      Your ADC_m and ADC_temp25 is not right, because you use the wrong temp sensor slop and the wrong Temp sensor voltage, you should refer to the KL05 datasheet instead of the AN3031, an3031 is just for HCS08.

    The correct temp sensor slope and temp sensor voltage is as follows:

pastedImage_1.png

    Please modify your code and test again.

Wish it helps you!

If you still have question, please contact me!


Have a great day,
(Jingjing)

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

1,298 Views
nguyennhatminh
Contributor IV

Hi Jingjing Zhou,

Thank you very much for your reply,

1.Code size : I created hex file and I see the value is about 35Kbyte. Do you know how to check code size of some line code ? please teach me.

2. Temp Sensor.

I was wrong in choosing Temp Sensor Slope. I check The Temp Sensor Slope is 1.62 mV/C  typical values and VTemp25 716. I refer to this doc  KL05P48M48SF1, Data Sheet: Technical Data, Rev 4 03/2014.

Thank you for this point , I understand the Temp Sensor Slope.

[code]/PMC_REGSC |= PMC_REGSC_BGBE_MASK;// Enable bandgap.

  (void) ADC0_MeasureChan(1,0);// Measure

   ADC0_GetChanValue(0,&ADC_BG);// Get value ADC from BANDGAP

  

   calcVDD=4095*1*10/ADC_BG;// 4095=2^12 bit ADC.

   ADC_temp25=4095*0.716*10/calcVDD;// Vtemp25=0.716 V, f ADC=2MHZ;

  

   while(1){

      

     (void)  ADC0_MeasureChan(1,1);

       ADC0_GetChanValue(1,&ADCR_temp);

      

       ADC_m=(4095*0.00162*10*100)/calcVDD;                    

      

       Temp=(25-(ADCR_temp-ADC_temp25)*100/ADC_m);

    

   }

[code]

I modified and the result is same the old one, i think.

and another thing , I also want to send this value by UART to terminate (PC), the value is 16bit, but UART just only send max 10 bit. Please give me some advise on this situation , if you have sample code is great. :smileywink:

Minh.

0 Kudos
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

  Do you have KL05P48M48SF1, Data Sheet: Technical Data, Rev 4 03/2014.?

   If you have , could you give me one, I will help you test your project.

   The datasheet what I have is just KL05P48M48SF1, Data Sheet: Technical Data,Rev. 3, 11/29/2012

  Our web situation is like follows:

pastedImage_0.png

    My document's data is different to you, so please give me your rev4 document, or maybe you refer to the wrong document.

Best regards,

Jingjing

0 Kudos
1,298 Views
nguyennhatminh
Contributor IV

Hello JingJing zhou,

Thank you very much for your help

Please see my attached file for the doc

Minh.

0 Kudos
1,299 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

      Thank you for your new version datasheet.

      I help you do a project, you can refer to it, please find the project from the attachment.

    I test it based on our FRDM_KL05, my test result print like following:

pastedImage_0.png

  Wish it helps you!

If you still have quesiton, please contact me!


Have a great day,
(Jingjing)

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

0 Kudos
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

    Answer your question 1: how to see the code size

(1) Open "PROPERTIES "

pastedImage_0.png

(2)

pastedImage_1.png

(3) Build

  After bulid, you will find the code size in the console window:

pastedImage_2.png

0 Kudos
1,298 Views
nguyennhatminh
Contributor IV

Hello Jingjing zhou,

Would you like explain to me more detail about information in Console Window ?

text         data bss         dec         hex       filename

13152         228             800       14180        3764     ReadMCU_temp.elf

'Finished building: ReadMCU_temp.siz'


The size of hex's file is 14180 byte =14kb , is that right ?


Thank,

Minh

0 Kudos
1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Minh,

     Sorry for my later reply, of course I would liket to explain it.

    Please check this link:1:[VxW] Re: What is bss, Data and Text exactly means, how it will be useful?. is there any types are t...

2:text, data and bss: Code and Data Size Explained | MCU on Eclipse

    It explain it in details.

   dec is the whole size of text , data and bss, it is decimal,

  hex is still the whole size of text , data and bss, it is hexadecimal,

Wish it helps you!

Best regards,

Jingjing