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

📄 flash.c

📁 ADuC系列芯片的源代码事例
💻 C
字号:
/*********************************************************************

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

 Date          : Sept. 2005

 File          : Flash.c , RAM.c

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

 Description   : This example demonstrate how to place the Interrupt 
 				 Vector Table in RAM, perform a REMAP, i.e. map RAM to
				 0x00, and wait in a loop for the XIRQ0 button to be 
				 pressed, and compliment p4.2.
		

 Note			: The memory regions in the linker have being changed.
				  The Data region is changed from Start 0x10000 and size
				  0x2000 to Start 0x10040 and size 0x1FC0.

*********************************************************************/

#include<ADuC7026.h>

//	Function Prototype section

void Install_ISR_Vector_Table(void);

extern void	My_IRQ_Function(void)  __attribute__((section(".ram_func"))) __attribute__((section (".ram_func")));

//	Main Function

int main (void)  
{
	FEEMOD = 0x8;
	Install_ISR_Vector_Table();

	GP4DAT 	= 	0x04040000;	   		// 	Enable P4.2 as an Output

	REMAP 	= 	0x01;				//	Remap Ram to 0x00 
	IRQEN 	= 	XIRQ0_BIT;

	while(1){						// 	Infinite loop
	}
	return(0);
}

/*********************************************************************

	This function copies the Vector table from flash and places it in
	RAM starting at 0x10000. The jump locations for IRQ,FIQ,etc. can 
	then be easily modified as shown below for IRQ.
		
*********************************************************************/

void Install_ISR_Vector_Table()
{
 	unsigned long *Vector_Destination, *Vector_Source;
	int i;

	// RAM Vector Table Start
	Vector_Destination	= (unsigned long * )0x10000;
	// Flash Vector Table Start		   	
	Vector_Source		= (unsigned long * )0x80000;


//	 Copy the the Vector Table into RAM
//
//Vectors:        LDR     PC, Reset_Address
//                LDR     PC, Undef_Addr
//                LDR     PC, SWI_Addr
//                LDR     PC, PAbt_Addr
//                LDR     PC, DAbt_Addr
//                NOP                            /* Reserved Vector */
//                LDR     PC, IRQ_Addr
//                LDR     PC, FIQ_Addr
//
//Reset_Address:  .word   Reset_Handler

	for (i=0;i<9;i++)
	{
		*Vector_Destination = *Vector_Source;
		*Vector_Destination++;
		*Vector_Source++;
	}

// Define jump locations as required

//	*Vector_Destination = (unsigned long )&My_UnDef_Function ;
	*Vector_Destination++;
//	*Vector_Destination = (unsigned long )&My_SWI_Function ;
	*Vector_Destination++;
//	*Vector_Destination = (unsigned long )&My_PAbort_Function ;
	*Vector_Destination++;
//	*Vector_Destination = (unsigned long )&My_DAbort_Function ;
	*Vector_Destination++;
	*Vector_Destination = (unsigned long )&My_IRQ_Function ;
	*Vector_Destination++;
//	*Vector_Destination = (unsigned long )&My_FIQ_Function ;

}

⌨️ 快捷键说明

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