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

📄 example_variable_placement.c

📁 Mplab C30编译器
💻 C
字号:

 /* Example illustrating how to locate a variable at a specific address*/

 /***********************************************************************
 *  In this example, array buf1 is located at a specific address in     *
 *  data memory. The address of buf1 can be confirmed by executing the  *
 *  program in the simulator, or by examining the link map.             * 
 *                                                                      *
 *  You can view the results of the printf statements by enabling the   *
 *  MPLAB SIM tool then enabling the UART1 I/O with Output set to       *
 *  Window. The printf results are then displayed in the output window. *
 *                                                                      *
 *  A defined heap size is required since we are using a standard I/O   *
 *  function.                                                           *
 *                                                                      *
 *                                                                      *
 *  For additional information about dsPIC architecture and language    *
 *  tools, refer to the following documents:                            *
 *                                                                      *
 *  MPLAB C30 Compiler User's Guide                        : DS51284    *
 *  dsPIC 30F MPLAB ASM30, MPLAB LINK30 and Utilities                   *
 *                                           User's Guide  : DS51317    *
 *  Getting Started with dsPIC DSC Language Tools          : DS51316    *
 *  dsPIC 30F Language Tools Quick Reference Card          : DS51322    *
 *  dsPIC 30F 16-bit MCU Family Reference Manual           : DS70046    *
 *  dsPIC 30F Programmer's Reference Manual                : DS70030    *
 *                                                                      *
 *  Example file has been compiled with MPLAB C30 v1.30.00              *
 *                                                                      *
 ************************************************************************
 *                                                                      * 
 *    Author:                                                           *
 *    Company:                                                          * 
 *    Filename:       Ex_Variable_Placement.c                           *
 *    Date:           02/01/2005                                        *
 *    File Version:   1.00                                              *
 *    Other Files Required: p30f6014.gld                                *
 *    Tools Used: MPLAB IDE -> 7.01.00                                  *
 *                Compiler  -> 1.30.00                                  *
 *                Assembler -> 1.30.00                                  *
 *                Linker    -> 1.30.00                                  *
 *                                                                      *
 ***********************************************************************/

/* Include the appropriate header (.h) file, depending on device used */
/* Example (for dsPIC30F5013): #include <p30f5013.h>                  */
/* Alternatively include the generic header file, p30fxxxx.h, as shown 
   below.                                                             */

	#include <p30fxxxx.h>
	#include "stdio.h"

int __attribute__((address(0x900))) buf1[128];


int main( void )
{
	printf("0x900 = 0x%x\n", &buf1);

	while ( 1 );
}



/* The equivalent array definition in assembly language appears below. The .align
   directive is optional and represents the default alignment in data memory. Use 
   of * as a section name causes the assembler to generate a unique name based on 
   the source file name. 

       .section *,address(0x900),bss,near
       .global _buf1
       .align 2
_buf1: .space 256

*/

⌨️ 快捷键说明

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