Memory Problem in PIC18F46K22

Thread Starter

Nebulas_PSP

Joined Aug 22, 2014
5
Hi All,

I am using controller 18F46K22 for one of my application under development.
The following are the problem that i am facing when i use this controller:
1. The frequency of Errors/Bugs which i am getting during the working of it, is not stable.
2. After some time interval variables are giving garbage values.

When i reported this problem to the vendor of the same controller, they responded with me saying, this controller may have memory leakage problem and they are under the research of the solution.

I will be very happy if you share your experience with me to sort out this issue, and please help me out as soon as possible guys :confused:

Regards,

Parashuram Patil,
Nebulas Kolhapur.
 

Thread Starter

Nebulas_PSP

Joined Aug 22, 2014
5
Thank you so much for your reply tshuck and joeyd999,

Its not programming error, i have checked it with Hardware debugger, and if it is programming error or the problem with logic, the error should be same at all the time right??
but its not :(

and another thing, after some time interval some random variables are assigned with garbage values, what might be the problem??
 

Thread Starter

Nebulas_PSP

Joined Aug 22, 2014
5
Hi tshuck,

just now i got updated information from the vendor of PIC18F46K22 that, this controller has memory leakage problem.

Might be the lot which we got :(
 

tshuck

Joined Oct 18, 2012
3,534
Hi tshuck,

just now i got updated information from the vendor of PIC18F46K22 that, this controller has memory leakage problem.

Might be the lot which we got :(
What do you mean by memory leakage? Most often, this refers to a programming practice of not releasing allocated memor. Do you mean to say that the flash memory is corrupted?

Its not programming error, i have checked it with Hardware debugger, and if it is programming error or the problem with logic, the error should be same at all the time right??
Not necessarily.
 

Thread Starter

Nebulas_PSP

Joined Aug 22, 2014
5
I mean to say, RAM variable values are getting changed randomly than what i set in the program.
Eg. Consider the follwing program code
if (SHOWDispWhat==1) SHOWDispWhat =2;
else if (SHOWDispWhat==2) SHOWDispWhat =3;
else if (SHOWDispWhat==3) SHOWDispWhat =4;
else if (SHOWDispWhat==4) SHOWDispWhat =5;
else if (SHOWDispWhat==5) SHOWDispWhat =6;
else if (SHOWDispWhat==6) SHOWDispWhat =7;
else if (SHOWDispWhat==7) SHOWDispWhat =8;
else if (SHOWDispWhat==8) SHOWDispWhat =9;
else if (SHOWDispWhat==9) SHOWDispWhat =10;
else if (SHOWDispWhat==10) SHOWDispWhat =11;
else if (SHOWDispWhat==11) SHOWDispWhat =12;
else if (SHOWDispWhat==12) SHOWDispWhat =13;
else if (SHOWDispWhat==13) SHOWDispWhat =1;

but when i display this variable "SHOWDispWhat" on LCD, after some time the value in this variable shows other than 1 to 13, whic is never assigned in the above code. like 182, 43, 50 etc.
 

joeyd999

Joined Jun 6, 2011
5,281
I got updated information from the vendor of PIC18F46K22 that, this controller has memory leakage problem.
WTH is a "memory leakage problem" WRT hardware?

"Memory leakage" usually means deallocated memory is not freed, and only pertains to high-level languages like C.

The 46K22 uses the same memory structure of all PICs (at least those that are fabbed with the same process). If that particular part "loses" its memory, I'd expect Microchip would have a serious problem with their fab -- resulting in *lots* of parts having the same problem.

This doesn't pass the smell test, regardless of what the "vendor" says. Is the vendor Microchip themselves? If so, please provide a link to the errata. I'd really like to see it as my business depends upon Microchip's quality.

EDIT: FYI, Microchip uses "static" memory, as opposed to "dynamic". Static memory doesn't "leak", in the strict sense of the word.

EDIT 2: Are you working in a location with a high incidence of gamma rays? If so, you've got more problems than just "memory leakage"!
 

joeyd999

Joined Jun 6, 2011
5,281
I mean to say, RAM variable values are getting changed randomly than what i set in the program.
Eg. Consider the follwing program code
if (SHOWDispWhat==1) SHOWDispWhat =2;
else if (SHOWDispWhat==2) SHOWDispWhat =3;
else if (SHOWDispWhat==3) SHOWDispWhat =4;
else if (SHOWDispWhat==4) SHOWDispWhat =5;
else if (SHOWDispWhat==5) SHOWDispWhat =6;
else if (SHOWDispWhat==6) SHOWDispWhat =7;
else if (SHOWDispWhat==7) SHOWDispWhat =8;
else if (SHOWDispWhat==8) SHOWDispWhat =9;
else if (SHOWDispWhat==9) SHOWDispWhat =10;
else if (SHOWDispWhat==10) SHOWDispWhat =11;
else if (SHOWDispWhat==11) SHOWDispWhat =12;
else if (SHOWDispWhat==12) SHOWDispWhat =13;
else if (SHOWDispWhat==13) SHOWDispWhat =1;

but when i display this variable "SHOWDispWhat" on LCD, after some time the value in this variable shows other than 1 to 13, whic is never assigned in the above code. like 182, 43, 50 etc.
More often than not, this error can be produced in at least the following possible ways:

1. An interrupt is firing between the setting of the variable and its display, causing a change in the variable;
2. You are not banking correctly, causing memory writes to modify locations different than expected;
3. You've got some code running off in an unexpected direction, causing corruption of some memory locations.
 

joeyd999

Joined Jun 6, 2011
5,281
Further, the Program Counter, as well as all other control registers, use the same kind of memory. If the problem is as you say, I am surprised anything is working at all, much less just giving wrong answers.
 

tshuck

Joined Oct 18, 2012
3,534
Is SHOWDispWhat ever initialized? If not, you can't expect it to behave properly.

I didn't see anything in the errata related to memory (and I wouldn't expect to). A code snippet doesn't really help as we can't see what you are doing with SHOWDispWhat.

Also, please put code in the code tags ([ code] [/ code] - without the spaces), add this makes it easier to read your code.
 
Last edited:

joeyd999

Joined Jun 6, 2011
5,281
Rich (BB code):
if (SHOWDispWhat==1) SHOWDispWhat =2;
else if (SHOWDispWhat==2) SHOWDispWhat =3;
else if (SHOWDispWhat==3) SHOWDispWhat =4;
else if (SHOWDispWhat==4) SHOWDispWhat =5;
else if (SHOWDispWhat==5) SHOWDispWhat =6;
else if (SHOWDispWhat==6) SHOWDispWhat =7;
else if (SHOWDispWhat==7) SHOWDispWhat =8;
else if (SHOWDispWhat==8) SHOWDispWhat =9;
else if (SHOWDispWhat==9) SHOWDispWhat =10;
else if (SHOWDispWhat==10) SHOWDispWhat =11;
else if (SHOWDispWhat==11) SHOWDispWhat =12;
else if (SHOWDispWhat==12) SHOWDispWhat =13;
else if (SHOWDispWhat==13) SHOWDispWhat =1;
Oh, and while we're at it, perhaps some better code construction would be helpful:

Rich (BB code):
SHOWDispWhat = (SHOWDispWhat == 13) ? 1 : SHOWDispWhat+1;
or, if you can start at 0 instead of one, it's even easier:

Rich (BB code):
SHOWDispWhat = (SHOWDispWhat+1)%13;
This will count from 0 to 12 (instead of 1 to 13).
 
Last edited:

BobTPH

Joined Jun 5, 2013
8,929
Despite your objections, I would give 10:1 odds that the problem is a programming error. Memory corruption type errors are common when using low-level languages, like assembler or C. And a compiler bug is still more likely than a problem with the hardware memory.

Bob
 

alfacliff

Joined Dec 13, 2013
2,458
I have run into programming problems where the programmer failed to alloow for undocumented commands. in other words, a combination of inputs that was not programmed for did things strangely. you have to keep track of what memory is used and clear it when it is not used. some try to ureuse memory in the same program, using a byte for temproary storeage of several variables, without clearing it after use.
 

RichardO

Joined May 4, 2013
2,270
It is also good practice to clear your data memory at reset time. This makes any variables that are not uninitialized in your code a known value -- even if it is not the right one. It also makes it easier to see when the contents of a memory location is not what you think it should be.
 
Top