View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
read eeprom and global interrupt PIC18F46K22 |
Posted: Tue May 04, 2021 1:55 am |
|
|
Hello,
Checking assembler generated from CCS V5.077 I realized CCS routine called "read_eeprom" set and reset global interrupt during eeprom read operation. Generally microchip datasheet don't request this for read operation. This happens also in read routine not under interrupt.
Somebody can explain me why ?
Thanks, |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue May 04, 2021 2:01 am |
|
|
Presumably just to avoid the possibility of anything in the interrupt code
changing a register setting that affects this. If you have any form of table
read operation in the interrupt (array access), this could cause problems.
Remember though that the 'read; is very fast, so unlike the write where
interrupts are disabled for a significant time, the effect of this should be
tiny. |
|
![](templates/subSilver/images/spacer.gif) |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Tue May 04, 2021 2:34 am |
|
|
I supposed so but I was considering whether this operation is not negligible.
I'm going to do some about it. My question comes because I have a random delay in phase controls under timer interrupt never saw before. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Tue May 04, 2021 4:37 am |
|
|
It's a 'better safe than sorry' chunk of code. As Mr. T. points out, the compiler can't 'know' all interactions of what your code could do, so prevents a possible event (interrupt) from altering a known event (R/W EEPROM).
As for the 'random delay' problem, post the ISR, maybe we can see something. Perhaps go back a few versions to a previously known 'good' version. Hopefully you have incremental versions of the program and not just one that you keep editing, and reediting, and reediting..... |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu May 06, 2021 1:03 am |
|
|
The time involved in a read should literally only be a handful of machine
instructions. |
|
![](templates/subSilver/images/spacer.gif) |
|