Page 1 of 1
step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 12:00 am
by khmok
Hi,
I am currently using PIC16F873A, MPLAB 8.46, UIC00B programmer/debugger and HI TECH compiler.
Below are few lines at the very beginning of main() where I trying to read and write data eeprom of PIC. I am using debug mode to step in each line and "watch" EEADD and EEDATA. However, something wrong when step into eeprom_write(): it stepping target few times and the arrow stop at some other line - in this case I2C_stop() (refer attachments EEPROM_WRITE_1 & EEPROM_WRITE_2).
can anyone help to explain this?
void main(void)
{
unsigned char rec_data[2];
unsigned char ee_mux_no = 0;
unsigned char address = 0;
unsigned char address2 = 1;
unsigned char value = 171;
ee_mux_no = eeprom_read(address);
eeprom_write(address,value);
ee_mux_no = eeprom_read(address2);
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 9:13 am
by robosang
As far as I know, when you read or write data from/to EEPROM, the timing is critical and it cannot be interrupt by other source. That is is why in datasheet, it is stated, when dealing with EEPROM, global interrupt is being disabled to prevent any possible interrupt source to disturb the process.
I guess when you are using debugger, it hold the process and the timing is incorrect and the process jump, that is just my point of view.
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 9:33 am
by khmok
I have tried to create a new project, where it only consists of eeprom_read and eeprom_write. Then I step into each function, there is no such problem.
So based on your opinion and my observation above, looked like the program has been interruptted during eeprom_write. But there are few things couldn't explaint this:
1. I don't use any interrupt in my code (hence no ISR).
2. Although I never disabled the IF (interrupt flag), but by default it is disable.
3. It only happen when eeprom_write() but not in eeprom_read().
4. The subroutine that the arrow point to is not ISR and neither the PEN is execute based on interrupt.
Please share more thoughts with me so that I can solve this problem. Thanks a lot.
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 10:05 am
by robosang
Yes, I understand there is not ISR or interrupt.
I highlight the interrupt because it is stated in the datasheet that even interrupt cannot happen during the EEPROM process, the main point is the timing to write cannot be disturb.
As I said at the end of my explanation, using debugger change the timing because you need to animate and hold the process to make it slower.
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 10:14 am
by khmok
Do you have any idea how to check the data EEPROM content without entering debug mode?
I want to make sure that the data written into EEPROM of PIC is successfully stored.
Thanks.
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 1:04 pm
by shahrul
Test it on real hardware.
Re: step into eeprom_write() but jump to other line

Posted:
Fri Mar 22, 2013 10:48 pm
by robosang
Yup, with real hardware.