Searching \ for '[PIC] dsPIC with ICD2 - what am I doing wrong?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devprogs.htm?key=icd
Search entire site for: 'dsPIC with ICD2 - what am I doing wrong?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] dsPIC with ICD2 - what am I doing wrong?'
2004\10\24@203417 by Herbert Graf

picon face
Hello everyone, trying to put together a VERY simple piece of code for
an upcoming project and I am absolutely frustrated (it's my first walk
into the hell of the ICD2). All I want to do is "watch" an array using
the ICD2. I keep getting "restricted memory" and "out of scope" messages
in the watch window. So, looking up the manual I see I need "extern", so
I add that, and get the following!@!??!

Anybody have a clue as to what I'm screwing up on? My code and the
output of the compiler are below. Thanks in advance for any help. TTYL

Clean: Deleting intermediary and output files.
Clean: Deleted file
"H:\Data\Projects\ClassDAmp\class_d_amp.o".
Clean: Done.
Executing: "C:\pic30_tools\bin\pic30-gcc.exe"
-D__dsPIC30F2010__ -c -x c "class_d_amp.c"
-o"class_d_amp.o" -g
Executing: "C:\pic30_tools\bin\pic30-gcc.exe"
-Wl,"H:\Data\Projects\ClassDAmp\class_d_amp.o",--script="H:\Data\Projects\ClassDAmp\p30f2010.gld",-L"C:\pic30_tools\lib",-o"class_d_amp.cof"
H:\Data\Projects\ClassDAmp\class_d_amp.o: In function
`main':
H:\Data\Projects\ClassDAmp\class_d_amp.c:57: undefined
reference to `ADC_array'
BUILD FAILED: Sun Oct 24 20:25:55 2004

My code:

#include "c:\pic30_tools\support\h\p30F2010.h"

#define FCY  2000000
#define MILLISEC FCY/10000                        // 1 mSec delay constant
//---------------------------------------------------------------------
// List interrupt and subroutine prototypes here

void InitADC12(void);
void SendADC(void);
void DelayNmSec(unsigned int N);
void __attribute__((__interrupt__))
_U1TXInterrupt(void);



unsigned char ADCbcd;
extern int ADC_array [128];    

 

//---------------------------------------------------------------------


int main(void)
{
       int i;
       InitADC12();        

       while(1)                       // loop forever doing
       {
               for (i=0; i<128; i++)
               {
                       ADCON1bits.SAMP = 1;
                       DelayNmSec(5);
                       ADCON1bits.SAMP = 0;
                       while (!IFS0bits.ADIF);
                       ADC_array[i] = ADCBUF0;
               }
               i = 0;
       }

}

____________________________________________

2004\10\24@210438 by Charles Craft

picon face


-----Original Message-----
From: Herbert Graf <spam_OUThgrafTakeThisOuTspamemail.com>
Sent: Oct 24, 2004 8:34 PM
To: "Microcontroller discussion list - Public." <.....piclistKILLspamspam@spam@mit.edu>
Subject: [PIC] dsPIC with ICD2 - what am I doing wrong?

<snip>


unsigned char ADCbcd;
extern int ADC_array [128];    

 
Should there be a space before the open square bracket?
Does it matter how big the array is in the extern statement?

Can you use "extern int ADC_array[]"?




____________________________________________

2004\10\24@212709 by Herbert Graf

flavicon
face
On Sun, 2004-10-24 at 21:04, Charles Craft wrote:
> -----Original Message-----
> From: Herbert Graf <hgrafspamKILLspamemail.com>
> Sent: Oct 24, 2004 8:34 PM
> To: "Microcontroller discussion list - Public." <.....piclistKILLspamspam.....mit.edu>
> Subject: [PIC] dsPIC with ICD2 - what am I doing wrong?
>
> <snip>
>
>
> unsigned char ADCbcd;
> extern int ADC_array [128];    
>
>  
> Should there be a space before the open square bracket?

No clue, same result either way, generally I've found C doesn't mind.
Note that if I REMOVE the extern it compiles fine, but then I get the
"restricted memory" message in the watch window.

> Does it matter how big the array is in the extern statement?

Doesn't seem to.

> Can you use "extern int ADC_array[]"?

Same result. In fact if I make ADC_array an int I STILL get the same
message.

Thanks, TTYL

-----------------------------
Herbert's PIC Stuff:
http://repatch.dyndns.org:8383/pic_stuff/

____________________________________________

2004\10\24@213137 by Herbert Graf

picon face
On Sun, 2004-10-24 at 21:27, Herbert Graf wrote:
> > Can you use "extern int ADC_array[]"?
>
> Same result. In fact if I make ADC_array an int I STILL get the same
> message.

Hmm, one thing in addition, if I deselect the ICD2 as debugger I still
cannot use the "extern", however I don't get the "restricted memory"
thing. When I recompile with the ICD2 selected as debugger I DO get the
"restricted memory" thing...

What does "restricted memory" mean anyways? Thanks, TTYL

____________________________________________

2004\10\24@214320 by WH Tan

flavicon
face
Hi Herbert,

As far as I know, the "extern" key word in C30 works same as ANSI C. It
means that something you declare in another file and you're importing it by
using the word "extern". I think that is the reason you get the compile
error.

I don't have my board with me now and I can't confirm it. But in my memory,
the last time when I worked with dsPICDEM, I didn't see that problem with a
global variable.

Anyway I'm wondering which paragraph of the manual that you're referring to.

Best regards,
WH Tan




{Original Message removed}

2004\10\24@215924 by WH Tan

flavicon
face
Now another thing frashing in my memory... did you check "Link for ICD2"
found under Project>Build Options...>Project. Under "MPLAB LINK30" tab...

{Original Message removed}

2004\10\24@223213 by Ken Pergola

flavicon
face

Hi Herbert,

You might be just running into how MPLAB IDE is currently defined to operate
with regard to the watch window and its "visibility" to variable scope.

Perhaps this thread might help you:

http://forum.microchip.com/tm.asp?m=43811&mpage=1&key=scope&anchor#44171

Best regards,

Ken Pergola


____________________________________________

2004\10\24@232359 by Herbert Graf

flavicon
face
On Sun, 2004-10-24 at 21:58, WH Tan wrote:
> Now another thing frashing in my memory... did you check "Link for ICD2"
> found under Project>Build Options...>Project. Under "MPLAB LINK30" tab...

BINGO!! Thanks, had no idea I had to click that. TTYL

-----------------------------
Herbert's PIC Stuff:
http://repatch.dyndns.org:8383/pic_stuff/

____________________________________________

2004\10\25@063430 by Alan B. Pearce

face picon face
>When I recompile with the ICD2 selected as debugger
>I DO get the "restricted memory" thing...

This suggests to me that the memory the ICD2 wants to use is taking up some
of the space that the array wants to use. Try re-arranging your RAM map.

____________________________________________

2004\10\25@074527 by olin_piclist

face picon face
Herbert Graf wrote:
> Hello everyone, trying to put together a VERY simple piece of code for
> an upcoming project and I am absolutely frustrated (it's my first walk
> into the hell of the ICD2). All I want to do is "watch" an array using
> the ICD2. I keep getting "restricted memory" and "out of scope" messages
> in the watch window. So, looking up the manual I see I need "extern", so
> I add that, and get the following!@!??!

EXTERN is used for accessing symbols between modules, which doesn't have
anything to do with the ICD2.  What PIC are you using?  The ICD2 requires
various resources that your code must stay away from.  This varies from PIC
to PIC.  On some PICs you define a particular global symbol and the linker
moves things around.  On others you have to make sure to not use certain
address ranges.

Another possibility is the electrical interface.  This is often a problem
even when hooked up according to Microchip recommendations, especially with
the faster PICs like the 30F.  Can you program the PIC using the ICD2 as a
programmer?  Can you program it using the ICD2 as the debugger?


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
____________________________________________

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...