View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
problem in debug with PIC16F630 |
Posted: Fri Nov 30, 2007 11:33 am |
|
|
Hi to all,
I have this problem since a long time but now I decided to solve it.
I use ICD debugger with header for PIC16F630. The sistem in assembler work fine and I tested.
Take a look to this simple software:
Code: |
#include <16F630>
#include <DEF630.c>
#if defined(debug)
#device icd=true
#fuses INTRC_IO,NOMCLR,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOCPD
#else
#fuses INTRC_IO,NOMCLR,WDT,PROTECT,PUT,BROWNOUT
#endif
#use delay(clock=4000000, RESTART_WDT)
void main(){
delay_cycles(1);
while(true){
delay_cycles(1);
}
}
|
here to you first part program memory in assembler:
Code: |
0000: NOP
0001: MOVLW 00
0002: MOVWF 0A
0003: GOTO 004
0004: CALL 3FF
0005: BSF 03.5
0006: MOVWF 10
0007: MOVLW 00
0008: MOVWF 0A
0009: GOTO 00A
.................... /*
|
In debug, with ICD2, the software stay in loop from line 0000 to 0004, and I can't realize why !
Somebody can explain me ?
Somebody has same problem ?
I use CCS V3,249 and MPLAB V7.40.
Thanks for help,
Regards,
Fabri |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Fri Nov 30, 2007 1:49 pm |
|
|
I remember but It doesn't work anyway ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 30, 2007 1:55 pm |
|
|
The code that you posted above does not have the #rom statement in it.
Add it, and see if it fixes the looping problem. The looping problem that
you described, is exactly what you would expect to see if the RETLW
instruction at address 0x3FF was erased.
First, read the program memory with MPLAB. Look at address 0x3FF.
Is there anything there ? (Such as a RETLW instruction). |
|
|
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
|
Posted: Fri Nov 30, 2007 8:01 pm |
|
|
osc cal might need to be at least 0x04
#ROM 0x3FF = { 0x34,0x4 } |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Sat Dec 01, 2007 2:13 am |
|
|
Hi,
After compiled with:
Code: |
#ROM 0x3FF = { 0x3400 }
|
in 0x3FF I found retlw0 but after send program to ICD2 in 0x3FF return 0x3FFFF. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 01, 2007 2:58 am |
|
|
Quote: | In 0x3FF I found retlw 0 but after send program to ICD2 in 0x3FF return 0x3FFFF. |
How did you get this value ? Did you use MPLAB and the ICD2 to read
the Program Memory ? Here is the procedure to read the memory:
Go to the programmer menu in MPLAB and select "Read". Then go
to the View menu and select Program Memory, and scroll down to
address 03FF. If the calibration memory is erased, then it will be 3FFF.
-------
If it is erased, then you can re-program it.
According to the 16F630 data sheet, it says the center frequency for
the OSCCAL register is selected when the register = 0x80. So you
should use the following #rom statement:
Code: | #rom 0x3FF = {0x3480} |
To program this value into the PIC, you have to tell MPLAB to allow it.
1. Go to the Programmer menu in MPLAB and select "Settings".
2. A window will pop up. Select the tab for "Calibration Memory".
3. There is a tick box that says:
Quote: | x Allow ICD2 to program calibration memory |
Enable that tick box.
4. There is a little box that says:
Quote: | New Value -- retlw: 0x80 |
Enter 0x80 as shown in bold above. Then click "Apply" and "OK".
5. Program the PIC.
6. After you program it, go back to that window, and if this box
Quote: | Allow ICD2 to program calibration memory |
is still selected, then un-select it.
I think this should fix the problem. |
|
|
|