View previous topic :: View next topic |
Author |
Message |
paddy
Joined: 04 Nov 2012 Posts: 15
|
Malfunction in working code!! |
Posted: Wed Jun 18, 2014 12:47 am |
|
|
Hi,
I am using MPLAB IDE version 8.60 and CCS compiler version 4.119 for programming of microcontroller PIC18F4520. I have working code which I am using since last 1 year. But suddenly I am facing a weird problem from couple of days. When I am reprogramming the micro controller it is not functioning as expected. The same hardware is working fine with earlier controller which were programmed couple of months back.
I am using pickit3 and MCD2 for programming micro-controller. Even changed the PC too. I really don't understand what is going wrong.
I have used MCP3208 ADC for reading 8 different values and display it on 7 segment display.
During testing I found that when I am putting fixed value (anything in between 0 to 4095) manually, everything seems working fine.
But when I am reading from actual ADC, it gives error in functioning.
I have never faced this problem before. I have not changed anything in code. I strongly feel that there is no issue in the code. Can you please tell me what are the other possibilities which may cause such problems.
Couple of months back I have re-installed the compiler because help files are not accessible due to newly installed antivirus.
Please advice.
Thanks
paddy |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Jun 18, 2014 7:05 am |
|
|
Hi,
Well, *something* has clearly changed, either in your code, or in your hardware. These systems don't randomly change their operation over time!
The key point is that you need to troubleshoot the problem. As a start, perhaps you can elaborate on this:
Quote: |
But when I am reading from actual ADC, it gives error in functioning.
|
What exactly does this mean? Please show the referenced code, and tell us what the error is!
If I had a dollar for every time I've heard "I have not changed anything in code", and "I strongly feel that there is no issue in the code", then I'd be relaxing on a beach somewhere.... .
John |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Jun 18, 2014 8:53 am |
|
|
Other obvious comment, is that re-installing MPLAB, may well have changed _it's_ settings. By default MPLAB compiles for DEBUG operation. The new install may well be doing this, which can easily prevent code from working. |
|
|
paddy
Joined: 04 Nov 2012 Posts: 15
|
|
Posted: Wed Jun 18, 2014 11:15 pm |
|
|
Hi,
Thanks for suggestions!!
I have re installed everything (CCS compiler as well as MPLAB IDE) and it starts working again!! Surprised Surprised
Thanks a lot for your help!! |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Jun 19, 2014 2:25 am |
|
|
Still sounds very odd to me. I mean, once your software is compiling without errors it should result in the same binary code every time you compile again. Re-installing the compiler shouldn't have effect on this unless you are doing some fancy stuff in your code that is environment dependent (conditional compiling, etc).
What I understand from your short description is that the program gets its input data from an A/D. When you feed the program manual data it works fine but using the A/D goes wrong?
If so, there can still be many things wrong but A/Ds are known to give many difficult to trace problems because they are connected to the world outside of your small PCB.
The easiest way to find these problems is using an oscilloscope on the A/D input and verify the input signal looks like what you expect. From experience on this forum I can tell you that many problems come from bad filtering or ground layer problems. Without more details this is impossible to pinpoint but it might be something silly as you neighbours air conditioning motor creating noise on the AC line. Or your project has two power supplies and a large ground current is going from one to the other; just disconnecting the ground wall socket or reversing the power plug on one of the power supplies might solve the problem.
These kind of problems will 'suddenly' pop up and disappear again without you changing any thing to your project. These can be maddening to find... |
|
|
|