CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

A struct in program memory [Solved]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 9:43 am     Reply with quote

Thank you!
I'm almost done. I can read and write correct data into ROM.

There is a problem, after multiple writes, I got cpu reset.
I could not find the reason.

Is it possible that a flash write cause reset?

Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 12:44 pm     Reply with quote

First thing, remember the CPU completely stops during the write.
Every peripheral needs to have some form of error recovery code
to deal with the situation that it receives something or an event happens
during the write. It could simply be that your code crashed because it
could not handle this.
Second thing though is that the write does draw quite a spike of current
on the supply rail, and it is vital that the supply is stable during this. If
the power droops or fails during the write, it can completely destroy
the program memory. Sufficient smoothing that the supply can be
guaranteed for the whole write.
Be aware just how quickly the chip's write life will get used if you write
at all frequently. You can destroy a chip in just 40 seconds doing repeated
writes.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 1:04 pm     Reply with quote

would need to see your program but...
a guess ...
do you have the WDT enabled ??
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 1:16 pm     Reply with quote

temtronic wrote:
do you have the WDT enabled ??

Bingo!
restart_wdt() resolved the issue.

@Ttelmah,
I will add some recovery code for communications.

Thanks for everything! That was a helpful topic.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 2:12 pm     Reply with quote

Normally you never enable the WDT until 100% of the code works and project is ready to be shipped to client. THEN you enable the WDT, do some tests, some calculations, configure the WDT registers, final tests and ship out.
jeremiah



Joined: 20 Jul 2010
Posts: 1314

View user's profile Send private message

PostPosted: Fri Dec 31, 2021 8:08 pm     Reply with quote

Another thing to consider is that erasing program memory does so in full blocks. Have you made sure no other code is in the same erase block as the structs you are writing to (which requires an erase)?
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Jan 01, 2022 1:02 am     Reply with quote

If you look earlier in the thread, that is the whole reason we justified the
data to be 64bytes in 'size'. Very Happy

Happy New Year everybody.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group