'btemp' is the name of a data 'psect' used to store temporary data everywhere in the program, library, etc. Any module that needs temporary storage just declares a 'btemp' 'psect' and use it. The linker joins all the 'btemp' 'psects' (overlaid, that is the resulting psect length is not the sum of the length of all of its component psects, but rather the length of the largest one). In C you should not need and even would not know about it, the compiler creates and uses it transparently to hold temporaries and return values. When writing assembly routines you may need to declare it yourself. Please note that you may declare any other temporary variable you want, but 'btemp' is convenient because it won't waste RAM as it will be joined with other 'btemps', while your other temporary variable will be allocated and used only by your routine. It seems that you hit a compiler's bug. Best regards, Isaac Em 14/11/2010 05:38, James Newton escreveu: > Another frustrating day... > > Very simple little program in HITECH C for the 12F675, randomly produces > this very strange error: > > aspic "\"--edf=3DD:\Program Files\HI-TECH Software\ > Error [800] C:\DOCUME~1\JAMESN~1.EFP\LOCALS~1\Temp\s3h4.; 353. undefine= d > symbol "btemp" > > Strange because no where in the program do my friend and I use the > identifier "btemp"... searching for btemp in the compiler manual finds: > "1. The BTEMP register is a memory location allocated by the compiler, bu= t > which is treated like a register for code generation purposes." > > Google for "undefined symbol btemp" finds: > c=3D1> > > In which the cryptic reply... > > Add the following bit of assembly: > > psect temp,ovrld,class=3DBANK0,space=3D1 > global btemp > btemp > ds 2 > =09 > You could put #asm/#endasm around it and add it to the C file. > > ...provides us with a solution. Apparently, it needs to be at the end of = the > C file? Anyway, adding that code allows for a successful compile, and > destroys my confidence in the compiler...=20 > > I mean... really? Are you kidding? The compiler is using an identifier th= at > is isn't bothering to define space for? And one that (although we didn't) > has a name any one could /easily/ crash on? > > Just for fairness, here is the program, so you can see how simple it is a= nd > maybe find something in it that could cause an issue. Actually, if someon= e > could try compiling this on their PC I would appreciate it; just to see i= f > it does the same thing to you with out the #asm block at the end.=20 > > BTW: the offending line seems to be the=20 > for (;speed < MID_SPEED;speed++)=20 > if you comment out that one line, it compiles without the asm block.=20 > > Also had to change=20 > > return (int)(ADRESH << 8 | ADRESL); > > (which seems more intuitive to me) into > > return (int)(ADRESH << 8 + ADRESL); > > or the same error appears. > > Here is the complete program (bugs, I'm sure, and all) > > #include > > __CONFIG (UNPROTECT > // & BORDIS //brown out reset disabled (default enabled) > & MCLRDIS //master clear reset on pin 3 disabled (default > enabled) > // & PWRTEN //power up timer enabled (default disabled) > & WDTDIS //watch dog timer disabled (default enabled) > & INTIO //internal osc, GP4,5 are IO (default RCCLK) > ); > #define _XTAL_FREQ 4000000 //required for __delay_ms macro > > #define AINbit 0 > volatile bit AIN @ (unsigned)&GPIO*8+AINbit; > #define STEPX GPIO1 > #define STEPY GPIO2 > #define STEPZ GPIO4 > #define DIR GPIO5 > > void init() { > TRISIO =3D 1< ANSEL =3D 1< ADCS0 =3D ADCS1 =3D 1; //RC clock > } > > typedef enum {cw=3D0,ccw=3D1} direction; > typedef enum {xaxis,yaxis,zaxis,aaxis} axis; > > #define MID_SPEED ((1<<10)/2) > #define DEAD_BAND 32 > > void step(axis anaxis, direction adir) { > DIR =3D 0; > STEPX =3D STEPY =3D STEPZ =3D 0; > DIR =3D adir; > switch(anaxis) { > case xaxis: STEPX =3D 1; break; > case yaxis: STEPY =3D 1; break; > case zaxis: STEPZ =3D 1; break; > } > }=09 > > int adc_read(unsigned char channel) > { > ADCON0 =3D (channel << 3);//0xC1; // enable ADC, RC osc. > ADON =3D 1; > VCFG =3D 0; //Vcc is our reference > ADFM =3D 1; //0=3DTop 8 bits of result in ADRESH,1=3D10bits in > ADRESH/ADRESL > GODONE =3D 1; > while(GODONE) > continue; // wait for conversion complete > return (int)(ADRESH << 8 + ADRESL); > } > > > void main() { > int speed; > direction dir; > init(); > while(1) { > speed =3D adc_read(0); > speed =3D MID_SPEED-speed; > dir =3D cw; > if (speed<0) {dir =3D ccw; speed =3D -speed;}; > speed -=3D DEAD_BAND; > if (speed < 0)=20 > continue; //no movement in dead band > for (;speed < MID_SPEED;speed++)=20 > __delay_ms(1); > step(xaxis,dir); > // step(yaxis,dir); > // step(zaxis,dir); > }=09 > } > =09 > #asm > psect temp,ovrld,class=3DBANK0,space=3D1 > global btemp > btemp > ds 2 > #endasm > > -- > James Newton > 1-970-462-7764=20 > > __________________________________________________ Fale com seus amigos de gra=E7a com o novo Yahoo! Messenger=20 http://br.messenger.yahoo.com/=20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .