⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variableplacement.c

📁 Applicable to ADuC702x rev H or I silicon
💻 C
字号:
/*********************************************************************

 Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : Sept. 2005

 File          : VarialbePlacement.c

 Hardware      : Applicable to ADuC702x rev H or I silicon
                 Currently targetting ADuC7026.

 Description   : Example program to illustrate variable location
 				 in memory using the GNU GCC compiler.
				 Terminal program required operating at 9600 - 8-N-1
		
*********************************************************************/

#include <ADuC7026.h>
#include <stdio.h> 
  

unsigned long i0;							//.bss		( RAM )
unsigned long i1 = 0x1234;					//.data		( RAM )
static unsigned long i2 = 0x1234;			//.data		( RAM )
const unsigned long i3 = 0x8764;			//.rodata 	( Flash )
static const unsigned long i4 = 0x8764;		//.rodata 	( Flash )
const static unsigned long i5 = 0x8764;		//.rodata 	( Flash )


extern int write (int file, char * ptr, int len);	/* Functions used  */
extern int getchar (void);							/* to output data 	 */
extern int putchar(int);                     		/* Write character to Serial Port  */


int main(void)
{
unsigned long i6;							//Stack		( RAM )
unsigned long i7 = 0x1234;					//Stack		( RAM )
static unsigned long i8 = 0x1234;			//.data		( RAM )
const unsigned long i9 = 0x8764;			//Stack		( RAM )
static const unsigned long i10 = 0x8764;	//.rodata  	( Flash )
const static unsigned long i11 = 0x8764;	//.rodata	( Flash )
 
  	// Setup tx & rx pins on SPM 0 and SPM 1
	GP1CON = 0x011;

   	// Start setting up UART at 9600bps
   	COMCON0 = 0x080;			// Setting DLAB
   	COMDIV0 = 0x088;			// Setting DIV0 and DIV1 to DL calculated
   	COMDIV1 = 0x000;
   	COMCON0 = 0x007;			// Clearing DLAB

	printf("Global Variable:\n");
	printf("\n	unsigned long i0;			is located in RAM ( 0x%X )",(unsigned int )&i0);
	printf("\n	unsigned long i1 = 0x1234;		is located in RAM ( 0x%X )",(unsigned int )&i1);
	printf("\n	static unsigned long i2 = 0x1234;	is located in RAM ( 0x%X )",(unsigned int )&i2);
	printf("\n	const unsigned long i3 = 0x8764;	is located in FLASH ( 0x%X )",(unsigned int )&i3);
	printf("\n	static const unsigned long i4 = 0x8764;	is located in FLASH ( 0x%X )",(unsigned int )&i4);
	printf("\n	const static unsigned long i5 = 0x8764;	is located in FLASH ( 0x%X )",(unsigned int )&i5);

	printf("\n\nLocal Variable:\n");
	printf("\n	unsigned long i0;			is located in RAM ( 0x%X )",(unsigned int )&i6);
	printf("\n	unsigned long i1 = 0x1234;		is located in RAM ( 0x%X )",(unsigned int )&i7);
	printf("\n	static unsigned long i2 = 0x1234;	is located in RAM ( 0x%X )",(unsigned int )&i8);
	printf("\n	const unsigned long i3 = 0x8764;	is located in RAM ( 0x%X )",(unsigned int )&i9);
	printf("\n	static const unsigned long i4 = 0x8764;	is located in FLASH ( 0x%X )",(unsigned int )&i10);
	printf("\n	const static unsigned long i5 = 0x8764;	is located in FLASH ( 0x%X )",(unsigned int )&i11);
	printf("\n");	

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -