View previous topic :: View next topic |
Author |
Message |
alanp
Joined: 27 Oct 2005 Posts: 6
|
Read_eeprom/interrupt halts PIC |
Posted: Thu Oct 27, 2005 11:39 pm |
|
|
Hi All,
I have a problem with read_eeprom halting my PIC16F876. I am using TMR0 to clock information out of port C. When the interrupt is running and I try to use the read_eeprom command the PIC halts.
From what I can see it is a similar problem to:
http://www.ccsinfo.com/forum/viewtopic.php?t=159&highlight=readeeprom+interrupt
CCS PCM C Compiler, Version 3.224
The disable/enable interrupts in the following code allows the code to function correctly, without it the PIC comes to a grinding halt.
Code: | .................... i=0;
016B: CLRF 4A
.................... do {
.................... disable_interrupts(GLOBAL); // Enable Interrupts
016C: BCF 0B.6
016D: BCF 0B.7
016E: BTFSC 0B.7
016F: GOTO 16D
.................... j = read_eeprom(i++);
0170: MOVF 4A,W
0171: INCF 4A,F
0172: MOVWF 4C
0173: BSF 03.6
0174: MOVWF 0D
0175: BSF 03.5
0176: BCF 0C.7
0177: BSF 0C.0
0178: BCF 03.5
0179: MOVF 0C,W
017A: BCF 03.6
017B: MOVWF 4B
.................... enable_interrupts(GLOBAL); // Enable Interrupts
017C: MOVLW C0
017D: IORWF 0B,F
.................... ax25_putc(j);
017E: MOVF 4B,W
017F: MOVWF 4D
0180: CALL 0F4
.................... } while (!(j & 1));
0181: BTFSS 4B.0
0182: GOTO 16C |
However the disable/enable interrupt in the following makes no difference and the code halts with or without it.
Code: | .................... disable_interrupts(GLOBAL); // Enable Interrupts
018C: BCF 0B.6
018D: BCF 0B.7
018E: BTFSC 0B.7
018F: GOTO 18D
.................... ax25_putc(read_eeprom(EE_SYMBOLTABLE));
0190: MOVLW 1E
0191: BSF 03.6
0192: MOVWF 0D
0193: BSF 03.5
0194: BCF 0C.7
0195: BSF 0C.0
0196: BCF 03.5
0197: MOVF 0C,W
0198: BCF 03.6
0199: MOVWF 4C
019A: MOVWF 4D
019B: CALL 0F4
.................... enable_interrupts(GLOBAL); // Enable Interrupts
019C: MOVLW C0
019D: IORWF 0B,F |
Has anybody else seen this problem or got any ideas on how to fix it.
Many thanks
AlanP |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Oct 28, 2005 6:01 am |
|
|
Got the watchdog enabled? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 28, 2005 11:30 am |
|
|
If you can post a really small test program that we can compile
and drop in on a demo board, then we can test this problem for you.
Be sure to post all #include, #fuses, and #use statements, and
keep the program small. |
|
|
alanp
Joined: 27 Oct 2005 Posts: 6
|
Solved |
Posted: Mon Oct 31, 2005 1:53 pm |
|
|
Hi All,
Well after alot of hunting around the list file I was able to fix this problem. I wrote my own ISR as the application is very time critical. The ISR only processed the TMR0 interrupt as this was the only one I was turning on.
However looking at the ENABLE_INTERRUPT(GLOBAL) instruction it enables both the GIE bit and the PEIE bit. As far as I know my code was not turning on any other interrupts apart from TMR0 but it was getting an interrupt from somewhere.
By using the assembly command BSF 0x8B,7 I was able to just turn on just the GIE bit and everything worked fine.
Thanks for the suggestions and thanks for all the work that everybody puts into the forum.
Cheers
AlanP |
|
|
|