 |
 |
| View previous topic :: View next topic |
| Author |
Message |
amatthews_1
Joined: 01 May 2026 Posts: 3
|
| New to CCS, issues with debugger. |
Posted: Fri May 01, 2026 4:32 pm |
|
|
Hello,
I am new to the CCS compiler, however I have used MPLAB w/ ICD 3 in the past.
I am currently using compiler v5.123 wiith ICD-U80 and I am have two main issues which I am assuming is user error. Any advice would help. I have searched the forums but did not find any solutions,
For hardware I am using the PIC12F683 dev board
1)Variables in the watch window show a ERROR#12 : Unidentified Identifier
All variables were selected from the drop down list.
I set a break point on the last line in the event, the variable is not in scope, but the error persists.
1)The "step over" function doesn't appear to be working.
When I run the code, the green error code goes to the Main function as expected. When I press the "step over" button or "step into" button again, nothing happens and the code appears to stop. When I press the "run" button nothing happens. I Halt / reset/ and run and the code runs normal, but I cannot step through the code.
Below is my code
| Code: | #include <12f683.h>
#device ICD=TRUE
#fuses intrc_io,nomclr,nowdt,noprotect
#use delay(clock=1000000)
#define RED_LED PIN_A4
#define YELLOW_LED PIN_A5
#define GREEN_LED PIN_A2
void main(){
int reading = 0;
setup_adc_ports( AN0_ANALOG );
setup_adc ( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
while(1){
output_high(RED_LED);
output_high(YELLOW_LED);
output_high(GREEN_LED);
int reading = read_adc();
int test = 22 ;
if(reading <=128 && reading >=25)
output_low(YELLOW_LED);
else if (reading < 25 )
output_low(RED_LED);
else
output_low(GREEN_LED);
// use line below as break point
reading = reading;
}
} |
**update #use delay(clock=1000000) was my issue with "step over" functionality. changed it to #use delay(clock=4000000) and the issue went away. Not sure why an incorrect delay would cause the debugger not to function, so any insights would be helpful.
I am still having issues with variables not displaying in watch window. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20075
|
|
Posted: Sat May 02, 2026 11:27 am |
|
|
There are quite a few things here.
First, are you using the 12F683 itself, or the debug extended version?.
Idk the former, you cannot have the NO_MCLR fuse and debug, since
it is the MCLR pin that the debugger uses. The debugger extended version,
is a special carrier, with the core of a 12F683 with extra pins to allow
debugging and the MCLR pin to still be used. Now normally the compiler
will override the NOMCLR instruction, but I'm not sure this will be done
with the fuse specified after the DEBUG line.
Then you say "the variable is not in scope". You will get "unidentified
identifier if you try to watch a variable when the code is not in the scope
of this variable, So you may well have your answer there. As a comment on
this though it is bad practice in C, to declare variables 'mid code'. This
makes the scope much more limited than it is if you always declare at the
start of a section. Separately though, have you got the variable 'type'
right for what you want to watch?. Remember CCS supports overloaded
variables, so INT FRED, is a different variable from CHAR FRED. So the
type you are declaring for your watch must match the variable you are
using. In CCS an 'int' is an int8 by default.
Also, beware of declaring a watch on the last line of a section of code.
The IDE habitually behaves as if you are at the line _after_ this point, so
may generate the fault you are seeing because of this. Stick a NOP
after the reading=reading line (delay_cycles(1);), and then break on
the reading=reading line, and see if that gives the correct result. |
|
 |
amatthews_1
Joined: 01 May 2026 Posts: 3
|
| Supplemental information |
Posted: Sat May 02, 2026 7:43 pm |
|
|
Thank you for your reply.
I am using the Pic12F683 dev version supplied by CCS. link below. It has the extra pins to allow for debugging as you mention below.
https://www.ccsinfo.com/product_info.php?products_id=12F683kit
The code I am using is taken from their supplied exercise book. Overall its just to get familiar with the compiler to use the basic A/D function. Everything in their sample code works. A/D functionality is one of the main aspects I am going to be using in a future project, so I want to better learn all aspects of debugging. Knowing the value the A/D reads is critical.
I agree, making a variable mid code isn't ideal, but for this I was just using their sample code. I created a global variable before the main loop, but that did not solve the issue. Since the reading is from the 8bit A/D, an int8 should suffice.
A also tried creating a test variable, both before, and inside the main() loop using the code below
I added that variable to the watch window and stepped through the code. I was able to get the "unidentified" error to disappear, but the watch window only had the variable as "0". Not sure how this is possible.
Thanks for the NOP recommendation. That is a better method of implementation. Unfortunately, it did not solve my issue.
I used the "auto" variable type in the watch window originally, but the switch to both int an char to try out, but no luck.
Is there a debugger specific setup that I may be missing? Its almost as if the watch window variable is pointing to an incorrect memory address to monitor. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20075
|
|
Posted: Sun May 03, 2026 6:28 am |
|
|
Yes. The PIC12F683-ICD. 14pin version of the chip.
You are using that chip not the 8pin one that also comes with the kit?.
That it is displaying the watch window, says you are in debug mode.
You are selecting debug from the compile tab, not just going directly
to the debug tab?. The code needs to be compiled to support debugging.
It should warn if you are not doing tis, but worth checking!... |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9641 Location: Greensville,Ontario
|
|
Posted: Sun May 03, 2026 8:29 am |
|
|
Curious,
Mr. T.....
this...
Remember CCS supports overloaded
variables, so INT FRED, is a different variable from CHAR FRED.
how does the compiler figure out which 'FRED' to use ?
Do you have to type INT and CHAR in front of every FRED in the program ??
Google wasn't much help for me.....sigh.... |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20075
|
|
Posted: Sun May 03, 2026 9:42 am |
|
|
Context.
If you have two variables with the same name, it looks at what it is being
used for.
My example there is bad, since char==int(8) on the smaller pics, but normally
what you use it 'for' determines which variable is selected. |
|
 |
amatthews_1
Joined: 01 May 2026 Posts: 3
|
| Solved |
Posted: Sun May 03, 2026 5:51 pm |
|
|
Ttelmah THanks for you help. Yes I am using the 14 pin chip. The 8 pin version that came with the kit is not installed.
I was pressing the "build and run" button in the Compile tab before enabling debug. Anytime I changed the code, the software automatically prompted me to rebuild and program before debugging.
update, Solved: I solved the problem by pressing the "clean" button in the Compile tab. After that, I hit the "build and run" button, and everything worked as expected. Thanks for pointing me in the right direction.
Is there any documentation on how the compiler operates? Perhaps a list of known issues, or other considerations. |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1983 Location: Norman, OK
|
|
Posted: Mon May 04, 2026 4:07 am |
|
|
The latest compiler User Manual is located here:
https://www.ccsinfo.com/downloads.php
I believe the latest updates/changes since the manual was issued can be found
in the CCSC.CHM Help file located in the compiler install directory (normally
PICC) where the compiler resides. Note there should be several other files in
the compiler directory that might be useful like FUSES.TXT and INTS.TXT.
Other good info can be found here:
https://www.ccsinfo.com/newsdesk_index.php?newsPath=ALL
They used to publish a list of latest compiler bug fixes/changes/updates but I am
unable to find that now so they must have moved it. _________________ Google and Forum Search are some of your best tools |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20075
|
|
Posted: Tue May 05, 2026 12:02 am |
|
|
The changes list is on the page for the compiler download selection.
However it is (and had always been), very incomplete...
Historically it was also important to look at the "readme.txt" with the
compiler, but CCS seem to have stopped updating this...
It sounds here as if the code had actually originally got compiled for
non debug use, and then the recompile option by default only looks for
changes in the code itself, and not for the 'target use', so kept flagging
that a full 'clean' build was not needed. Duh... |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1983 Location: Norman, OK
|
|
Posted: Tue May 05, 2026 3:57 am |
|
|
I found the Recent Changes list on the Compiler Downloads page just where
you said it was.. thank you. Strangely I never scrolled down to More Options
and and saw that link, I always got it from a drop down off the main website
menu bar (until it disappeared). I noticed the readme.txt stopped getting
updated a few years back, that's how I found the .chm file. That seems to be
the only place they are updating now. _________________ Google and Forum Search are some of your best tools |
|
 |
|
|
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
|