I know is not desired within ISR using : delay, long print, etc
but what about writing to EEPROM ?
I know is not desired within ISR using : delay, long print, etc
but what about writing to EEPROM ?
Delay will not work at all inside an ISR, and printing normally jams up things eventually.
Yes you can do that, although the operation takes a long time, in the order of 2-3mS, but it should be fine.
please explain why it is important to write to the eeprom inside the ISR.
The normal way ISRs are used is to set a flag-variable that indicates what has happened and then check the value of the flag-variable
outside of the ISR.
If you describe your whole project much better suggestions can be made
best regards Stefan
That was fixed (the code checks if interrupts are disabled)
I totally agree that usually ISRs are used is to set a flag-variable
but sometimes, for example, in the process of debugging, I print a short text to the terminal within ISR.
related to EEPROM - just to know if it possible w/o any issues
also could you please help me understand
what the value (range) should be used for address when we put this value for EEAR register
is the range between 0-1024 or need real physical address of flash like 0x03ff..0x04ff
if real address then what the range should be used for atmega328p ?
did you try with the Library? It makes life easier
(mind the 100,000 write max, hope your ISR is not triggered often)
I know with library much easier
but with register size of sketch much smaller , plus I want to learn how work with registers
just need to understand what the range for address
You have 1024 EEPROM bytes on the ATmega328P
as you have more than 256 bytes, the register has a Low and High part and address ranges from 0 to 1023
I found in avr macros the end address is 0x3FF so looks like range is from 0 to 1023
but I cant understand the following
for 1023 is need 10 bits but according datasheet we have only 9 bits for address
Bits 15..9 – Res: Reserved Bits
Bits 8..0 – EEAR8..0: EEPROM Addres
in additional in the datasheet is written - "EEAR8 is an unused bit in ATmega328P and must always be written to zero"
so final result - we have only 8 bits for address = 0..255
??? Im confused
I think I had found in the past as well the doc with only 1 bit in EEARH butI found other docs and if you look at the image in my previous post you see bits 9:8 are actually used by EEARH ➜ so you get 10 bits total which is enough for representing 0 to 1023
thank you!
will try
Then it will foul up millis()
.
but sometimes, for example, in the process of debugging, I print a short text to the terminal within ISR.
Might this not create bugs?
Then it will foul up
millis()
.
If it does you can reenable the interrupts when you have set the write in motion and are just waiting for the flag to tell you the write is finished.
Might this not create bugs?
its working fine (1-2 words)
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.