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

HEF many write cycles
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Sep 25, 2021 2:10 am     Reply with quote

One comment though. You seem to just be talking about storing something
like a 'count' of how many times the signal goes off/on, or just that it is
actually off/on. Both seem rather pointless. Unless you know 'when' the
signal changes, knowing how many times it has changed can be done far
easier with simple mechanical counter. Knowing that it is off or on, well
again the light itself says this. This is why I expected you would really need
something like 'when' it had changed to actually say anything useful. If this
is only a low frequency signal, one way that this could easily be done, is just
to keep the PIC powered. I have remote control units using small PIC's
like this that run for several years on a simple button cell, at a low speed
like 32KHz. If you don't need anything 'quick', this is a much easier solution
than trying to use the HEF.....
temtronic



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

View user's profile Send private message

PostPosted: Sat Sep 25, 2021 7:15 am     Reply with quote

hmm, I'm thinking he wants to 'restore' the light based on what it was before the PIC power was lost. if the light was on, then turn the light on when PIC program runs again. If off before ,then leave light off
So a 'restore to previous condition' flag, not an actual counter of 'on-offs'.

There's a huge problem with the English language, so many ways to describe what you want but then even more ways to interpret what is written....At 68 I'm still trying to figure it out.... Sad
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Sat Sep 25, 2021 10:42 am     Reply with quote

temtronic wrote:
hmm, I'm thinking he wants to 'restore' the light based on what it was before the PIC power was lost. if the light was on, then turn the light on when PIC program runs again. If off before ,then leave light off
So a 'restore to previous condition' flag, not an actual counter of 'on-offs'.

There's a huge problem with the English language, so many ways to describe what you want but then even more ways to interpret what is written....At 68 I'm still trying to figure it out.... Sad


That's exactly what you described I need.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Sat Sep 25, 2021 10:48 am     Reply with quote

a doubt, when I connect the pic to pickit3, it shows me pic 10F322, which is powered from 2.3 to 5.5V, if this pic were the 10(L)F322 which is powered from 1.8v to 3.6v the pickit3 would show the letter (L) ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 1:08 am     Reply with quote

Try reading the device ID byte, and see if the ID is for a 10F or a 10LF.
It is possible that the PK3, just reports 10Fxxx, for both chips.
The device ID's are in the 'programming specifications' data sheet for the
chips. Should be 0xAC for the 322, and 0xAE for the L version.

Now on this 'restore last state' program, what puzzles me with this is if
the chip is driving the light based on an external signal, then even if you
store the 'last' state, this will be overridden by the current state of the
signal?.
Seems to imply that the control must be coming from something other
than a simple input. Possibly a remote control signal or something
similar?.
In all cases there is a very large problem, unless you can detect that
a power fail is happening. The reason is that if a write to the flash memory
is occurring when the power fails, this can result in complete corruption of
the flash memory. So using the HEF, could be a 'disaster waiting to
happen', unless you can add circuitry to detect that the power is failing.
Sad This is a caveat with all writes like this. The same is true (but less
disastrously), to writes to EEPROM. 'Less disastrously', since corruption
of this does not corrupt the actual program code, but it still results in
corruption of the memory sometimes. If you can arrange to detect that
a power failure is happening, then this makes the 'only write when the
power goes off' solution a much better was to go.
I think you are probably going to have to rethink your hardware a little
to have any hope of making this actually work reliably.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Mon Sep 27, 2021 5:25 am     Reply with quote

Ttelmah wrote:
Try reading the device ID byte, and see if the ID is for a 10F or a 10LF.
It is possible that the PK3, just reports 10Fxxx, for both chips.
The device ID's are in the 'programming specifications' data sheet for the
chips. Should be 0xAC for the 322, and 0xAE for the L version.

Now on this 'restore last state' program, what puzzles me with this is if
the chip is driving the light based on an external signal, then even if you
store the 'last' state, this will be overridden by the current state of the
signal?.
Seems to imply that the control must be coming from something other
than a simple input. Possibly a remote control signal or something
similar?.
In all cases there is a very large problem, unless you can detect that
a power fail is happening. The reason is that if a write to the flash memory
is occurring when the power fails, this can result in complete corruption of
the flash memory. So using the HEF, could be a 'disaster waiting to
happen', unless you can add circuitry to detect that the power is failing.
Sad This is a caveat with all writes like this. The same is true (but less
disastrously), to writes to EEPROM. 'Less disastrously', since corruption
of this does not corrupt the actual program code, but it still results in
corruption of the memory sometimes. If you can arrange to detect that
a power failure is happening, then this makes the 'only write when the
power goes off' solution a much better was to go.
I think you are probably going to have to rethink your hardware a little
to have any hope of making this actually work reliably.


As we know there is a difference in operating voltage between the "normal" and "L" versions
when I go to program the chip, I have to set 3.6V in the programmer, if I leave 5V it shows an error, so I think this would be the L version.
Where do I read this Byte?

I understand the issue about writing to flash during a power failure and it corrupts, thanks for guiding me on this.

I am considering adding a 24lc01 memory, I think this would be the simplest way and I would have approx. 1 million writes/reads.
What do you say?
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Sep 27, 2021 7:38 am     Reply with quote

Though a lot better, it still involves a slow write. On the EEPROM, if a
write gets interrupted, only one byte would be damaged. However I still have
to just recommend a clock chip. Uses the same number of wires as the
EEPROM, and gives you RAM, that writes instantly (nSec).
If you are adding parts, then there are 8pin PIC's that have the EEPROM built
in, instead of HEF, or offer a power fail interrupt (or a comparator that can
give this).
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Tue Sep 28, 2021 4:57 am     Reply with quote

Ttelmah wrote:
Though a lot better, it still involves a slow write. On the EEPROM, if a
write gets interrupted, only one byte would be damaged. However I still have
to just recommend a clock chip. Uses the same number of wires as the
EEPROM, and gives you RAM, that writes instantly (nSec).
If you are adding parts, then there are 8pin PIC's that have the EEPROM built
in, instead of HEF, or offer a power fail interrupt (or a comparator that can
give this).



Ok, since I'm in Brazil, I have to select the PIC I use very well, because we don't have all the variety of PICs I would like.
which clock chip do you suggest?
temtronic



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

View user's profile Send private message

PostPosted: Tue Sep 28, 2021 5:19 am     Reply with quote

I just checked www.banggood.com and they have DS1307/AT24C32 modules for $3 each( $9 for 3 pcs), and DS3231/AT24C32 for $12 for 3 pcs, CDN money.
The DS3231 is a far more accurate RTC, but only 7 bytes of battery backed RAM, the DS1307(older RTC..) has more BB RAM but less accurate clock.

While I don't have a problem getting PICs, I decided years ago to buy ONE big PIC, the PIC18F46K22 , and use for ALL my projects. It has 40 pins, lots of memories, 2HW UARTS, etc. Far more 'stuff' than needed, BUT, it has allowed me to create my own libraries of working functions and almost 'know' the PIC. There's also the baby sister 26K22,less pins. While is does cost $1 or 2 more than the 'perfect PIC for a project', I KNOW it WILL work. Also, instead of buying a PIC with builtin USB, I chose to buy external TTLUSB modules. yes, it costs me $1 more than a handful of parts BUT they work, NO code needed either.
So while it costs more for the parts, I save on R&D time, which saves money and gets the projects finished faster.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Wed Sep 29, 2021 7:40 am     Reply with quote

Thanks for the previous answers.

I had a doubt, is it possible to use a mosfet as a 1bit memory?
I read somewhere that it keeps the last state, how would that work, or am I crazy?
temtronic



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

View user's profile Send private message

PostPosted: Wed Sep 29, 2021 7:54 am     Reply with quote

crazy...
Reality is that even though you only need 1 bit of memory .... 3 days from now, you'll need a whole byte , or 2 or 3 or 8........
projects NEVER,EVER get smaller..they expand to comsume ALL the resources of the PIC, and then some.
Last one I did, client 'needed' another 3 LEDS,sigh, that used up all but 1 pin of the 46k22 ! I came close to Charliplexing.....
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Wed Sep 29, 2021 8:02 am     Reply with quote

In this project I would really only need 1 bit to save the last state.
But ok, thanks for answering.
jeremiah



Joined: 20 Jul 2010
Posts: 1314

View user's profile Send private message

PostPosted: Wed Sep 29, 2021 6:32 pm     Reply with quote

I believe they make non volatile latches you can buy, which would be one bit.

As far as the mosfet route, it won't do it on its own. You'll need some sort of capacitance to hold the state once power is cut. For that you need to determine how long the power will be off and pick a capacitance that will hold the charge some percentage longer than that for wiggle room.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Sep 30, 2021 12:47 am     Reply with quote

What is being wanted, could be done simply with a couple of CMOS gates.
As Jeremiah says, with a bit of added capacitance. Use low leakage capacitors
and a value could be held easily for weeks. No need for a PIC at all.
temtronic



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

View user's profile Send private message

PostPosted: Thu Sep 30, 2021 5:02 am     Reply with quote

or, just use 1 bit from the core memory of a PDP-5/8.
gee, ANYONE have any ? Mine got tossed few year back,by mistake.
I can't see any option truly cheaper in parts/labour/R&D time than a $2 RTC module or a different PIC.
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, 3  Next
Page 2 of 3

 
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