CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problem in debug with PIC16F630

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

problem in debug with PIC16F630
PostPosted: Fri Nov 30, 2007 11:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 12:31 pm     Reply with quote

You asked this same question two years ago:
http://www.ccsinfo.com/forum/viewtopic.php?t=25539
Ttelmah gave you the answer at that time.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 1:49 pm     Reply with quote

I remember but It doesn't work anyway !
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 1:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 30, 2007 8:01 pm     Reply with quote

osc cal might need to be at least 0x04

#ROM 0x3FF = { 0x34,0x4 }
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Sat Dec 01, 2007 2:13 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 01, 2007 2:58 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group