Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/05/08 23:17
Read: times


 
#150358 - answer to quiz!
Responding to: ???'s previous message
First clue: I said each of the 32 scenes required 8 bytes, so all scenes require a total of 256 bytes.

Second clue: I said that when stepping through the code, the page-write function always thought that it was told to write zero bytes.

Third clue: the page-write function call used unsigned char as the type for the number-of-bytes-to-write argument.

-----------------------------------------

Answer: what's the largest value of an unsigned char? 255, of course, and 256 is greater than 255. I used the sizeof() operator to fetch the size of my scene buffer in RAM to use as the number-of-bytes argument. So the compiler helpfully truncated 256 into 8 bits, resulting in ... zero. And so nothing was actually written to the flash, and at power-up I fetched garbage.

The solution was to make the bytes-to-write parameter an unsigned int. (An alternative solution would have been to hard-code it and not pass that big a parameter but my flash-write code is supposed to be generic. But I was not worried about space and speed here so it works well enough as is.)

------------------------------------------

Crux of the biscuit for the OP: your reset and such is probably fine. Check your code! Make sure you're doing what you think you're doing!

-------------------------------------------

Red herring: it seems like the 8051F314's internal SRAM is capable of retaining its memory for lots of minutes, or at least until the big electrolytics on the 3.3V rail finally bleed off. Since the micro was retaining its memory, I was fooled into thinking that the flash write was working when it wasn't.

-a

List of 32 messages in thread
TopicAuthorDate
C8051F340 Flash corruption problem            01/01/70 00:00      
   use an open collector supervisor ana a pullup            01/01/70 00:00      
   No problem on my end            01/01/70 00:00      
      Grant, can you confirm            01/01/70 00:00      
         Not at this time            01/01/70 00:00      
         Yes, it's a 4k7 pullup            01/01/70 00:00      
   Why do you believe it's going awry during powerup?            01/01/70 00:00      
      likelyhoods            01/01/70 00:00      
         This is funny!            01/01/70 00:00      
            statistical probability            01/01/70 00:00      
               So you conclude that the world is flat?            01/01/70 00:00      
                  who on earth in his right mind would do that?            01/01/70 00:00      
                     someone who is curious about RESET.            01/01/70 00:00      
                        8051f12x/f13x            01/01/70 00:00      
                           It's not that simple ...            01/01/70 00:00      
                              I have a paid job            01/01/70 00:00      
                                 Indeed you have            01/01/70 00:00      
                                    if 1 million people get sick ...            01/01/70 00:00      
                                       It ain't necessarily so            01/01/70 00:00      
                                          3 things you did not respond to            01/01/70 00:00      
                                             that's not how it works            01/01/70 00:00      
                                                it his not 'details'            01/01/70 00:00      
                                                   What does "works" mean?            01/01/70 00:00      
   SiLabs view on this issue            01/01/70 00:00      
      re a point            01/01/70 00:00      
         I am reading some interesting discussion            01/01/70 00:00      
            AP, yes, Richard read that all say the same.            01/01/70 00:00      
            That means NO??            01/01/70 00:00      
               HUH?            01/01/70 00:00      
   Qazi Please provide some details            01/01/70 00:00      
   flash corruption or write failure            01/01/70 00:00      
      answer to quiz!            01/01/70 00:00      

Back to Subject List