Can an unitialised bit change it's state? - Page 1
Forum section: electronics / general

author: Circlotron
author_rank: Super Contributor
timestamp: August 04, 2022, 12:17:02 am
content: Background to the question - I used several bits in a particular RAM byte as flags. They would be set at power up if certain external conditions were yes. The mistake I made was not clearing the RAM first, and so sometimes those bits that should have been clear would be randomly set...So, the question is, if a bit is not specifically set or cleared at power up, can it be kind of borderline halfway and perhaps be read as a 0 for a while and later drift be read as a 1? Sort of like when an input pin is left floating and eventually drifts across the low/hi threshold.------I never picked up this non-cleared RAM problem until just now. HC908 micros never gave a problem for quite a few years. Switched to S08PA micros three years ago and still no problems. Then switched to S08FL because of chip shortages and this is where it all started. Those micros have been a pain in the butt for a number of reasons, but it's an ill wind that blows nobody no good. At least I found a bug that I probably wouldn't have otherwise.

author: ejeffrey
author_rank: Super Contributor
timestamp: August 04, 2022, 02:00:06 am
content: No. SRAM is bistable. It will land on a 0 or 1 within nanoseconds after the power rail is stable and stay there indefinitely. DRAM will be driven to a logical state at the first read or refresh

author: Geoff-AU
author_rank: Frequent Contributor
timestamp: August 04, 2022, 02:01:18 am
content: SRAM will pick a state and stay thereDRAM will be refreshed and whatever state is read the first time will be reinforced by the refresh so it'll stay there toobut *.RAM being in an unknown state at startup is an important paradigm to be aware of. Your startup sequence should initialise anything it's using in RAM to a known state (the C compiler does this for simple variables but if you're assigning a flag to a fixed RAM address then the compiler won't automatically zero it for you). Also.. if you assign but don't initialise an array then its contents will be whatever was in that memory beforehand.

author: srb1954
author_rank: Super Contributor
timestamp: August 04, 2022, 02:24:06 am
content: Quote from: ejeffrey on August 04, 2022, 02:00:06 amUnless it is hit by a powerful cosmic ray.

author: free_electron
author_rank: Super Contributor
timestamp: August 04, 2022, 03:01:37 am
content: Quote from: srb1954 on August 04, 2022, 02:24:06 amone alpha particle is enough ...

author: Circlotron
author_rank: Super Contributor
timestamp: August 04, 2022, 03:10:23 am
content: Okay. I'll put something like the following in right at the start.Code:CLRXCLR_LOOPCLR$40,XDBNZXCLR_LOOPIt would only clear the first 256 bytes (starting at $40) of course, but my stuff only uses about 50-60 bytes max.

author: Circlotron
author_rank: Super Contributor
timestamp: August 18, 2022, 01:09:54 am
content: Quote from: Circlotron on August 04, 2022, 12:17:02 amUpdate on this - it turns out it was not the fault of the different micro. When I ported the code to the FL micro I forgot to include the line that specifically clears the flags RAM byte. I should have cleared all used RAM right from the start. If you believe the data sheet then the basic code *should* run on all versions in that micro family, but it ain't so. The DDRs are one example. And the clock setup details...