PDA

View Full Version : Ram Gets Cleared



ljubex
- 6th November 2005, 14:40
Hi everybody,
I work with Pic 18F452 and have strange problem. In some moment all RAM data goes to 0. I guess that it happens because of bad power supply or something, but does anyone know WHY is this happening and how to solve the problem.

Thanks a lot

mister_e
- 6th November 2005, 18:24
Could be many things... any code and schematic?

Did you tried disable the brown-out reset fuse?
Is MCLR attach to VCC
Any floating pins?
Too much nested gosubs?
Circuit on a solid PCB or on a proto-board?
Battery powered or bench psu?
Supply line clean and properly filtered (caps around and close to PIC (at least)?
Any possible messy or loose contacts crystal, supply rails, ... , ....?
...?

ljubex
- 6th November 2005, 23:38
Not solved yet, but I hope it wan't be a problem. The situation was that on reset initial values of all data in one program section was set to zero. This is what compiler is doing, we didn't know that. We use Hi-Tech's compiler. Here is their explanation:

"Any object file may contain bytes to be stored in memory in one or more program sections, which will be referred to as psects. These psects represent logical groupings of certain types of code bytes in the program. In general the compiler will produce code in three basic types of psects, although there will be several different types of each. The three basic kinds are text psects, containing executable code, data psects, containing initialised data, and bss psects, containing uninitialised but reserved data. The difference between the data and bss psects may be illustrated by considering two external variables; one is initialised to the value 1, and the other is not initialised. The first will be placed into the data psect, and the second in the bss psect. The bss psect is always cleared to zeros on startup of the program, thus the second variable will be initialised at run time to zero. The first will however occupy space in the program file, and will maintain its initialised value of 1 at startup. It is quite possible to modify the value of a variable in the data psect during execution, however it is better practice not to do so, since this leads to more consistent use of variables, and allows for restartable and romable programs. For more information on the particular psects used in a specific compiler, refer to the appropriate machine-specific chapter."

In situation where electricity is bad, we've got resets frequently. I hope this will be usefull for somebody else.

Thanks again!