pravin b
Member level 5
- Joined
- May 20, 2012
- Messages
- 85
- Helped
- 2
- Reputation
- 4
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- Mumbai, India
- Activity points
- 2,083
Hello Friends,
I am using PIC18F4520, IDE- MPLABX v3.65, compiler- hitec picc18.
I have one variable unsigned long AdcValue which contains reading of adc corresponding to temperature. Now, I have another variable float DecTemp which contains temperature in decimal. Calculation is: DecTemp=(AdcValue/10)/1000; i.e. if AdcValue = 316589 then DecTemp will be 031.658 deg cel.
To achieve this, the simple and correct (according to me) peice of code will be;
But whenever I execute this code my PIC18f4520 gets reset on keypress and I am not able to understand why!!!:-x:-x:-x
It has something to do with memory requirement??? (I have filled code memory = 62FAh of 8000h bytes ( 77.3%) & data memory = 2EDh of 600h bytes ( 48.8%). Or is it because of 8 bit architecture on PIC18F4520???
Please help me out and let me know what I am missing. Thanks in advance.
Note: if i will comment out this line from my code, machine will not reset on keypress. Infact if i will carry out any arithmetic operation on AdcValue machine gets reset on keypress and if i comment that line it will not.
I am using PIC18F4520, IDE- MPLABX v3.65, compiler- hitec picc18.
I have one variable unsigned long AdcValue which contains reading of adc corresponding to temperature. Now, I have another variable float DecTemp which contains temperature in decimal. Calculation is: DecTemp=(AdcValue/10)/1000; i.e. if AdcValue = 316589 then DecTemp will be 031.658 deg cel.
To achieve this, the simple and correct (according to me) peice of code will be;
Code:
DecTemp=(AdcValue/10.0)/1000.0;
It has something to do with memory requirement??? (I have filled code memory = 62FAh of 8000h bytes ( 77.3%) & data memory = 2EDh of 600h bytes ( 48.8%). Or is it because of 8 bit architecture on PIC18F4520???
Please help me out and let me know what I am missing. Thanks in advance.
Note: if i will comment out this line from my code, machine will not reset on keypress. Infact if i will carry out any arithmetic operation on AdcValue machine gets reset on keypress and if i comment that line it will not.
Last edited: