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

📄 lib_flash_at49.c

📁 使用JTAG口对AT91R40008芯片进行FLASH编程的程序
💻 C
字号:
//*-----------------------------------------------------------------------------//*      ATMEL Microcontroller Software Support  -  ROUSSET  -//*-----------------------------------------------------------------------------//* The software is delivered "AS IS" without warranty or condition of any//* kind, either express, implied or statutory. This includes without//* limitation any warranty or condition with respect to merchantability or//* fitness for any particular purpose, or against the infringements of//* intellectual property rights of others.//*-----------------------------------------------------------------------------//* File Name               : lib_flash_at49.c//* Object                  : FLASH programmer for ://*                             - AT49BV1604/AT49BV1604T//*                             - AT49BV1614/AT49BV1604T//*                             - AT49BV8011/AT49BV8011T//*                             - AT49BV8011/AT49BV8011T//*//* 1.1 06/11/00 JPP        : Creation//*-----------------------------------------------------------------------------//* --------------------------- include file ----------------------------------#include    "lib_flash_at49.h"#define LED_3		1<<3#define LED_4		1<<4#define LED_5		1<<5#define LED_6		1<<6#define LED_16		1<<16#define LED_17		1<<17#define LED_18		1<<18#define LED_19		1<<19//* testvoid led_on(int state, int led){	int *pt=(int *)0xFFFF0030;	if (state)	pt++;	*pt = led;}//*----------------------------------------------------------------------------//* Function Name       : read_dbg_data//* Object              : read debug communication data register//* Input Parameters    ://* Output Parameters   : R0//*----------------------------------------------------------------------------extern u_int read_dbg_data(void);//*----------------------------------------------------------------------------//* Function Name       : read_dbg_control//* Object              : read debug communication data register//* Input Parameters    ://* Output Parameters   : R0//*----------------------------------------------------------------------------extern u_int read_dbg_control(void);//*----------------------------------------------------------------------------//* Function Name       : write_dbg_data//* Object              : read debug communication data register//* Input Parameters    : Val = R0//* Output Parameters   ://*----------------------------------------------------------------------------extern void write_dbg_data(u_int val);//*----------------------------------------------------------------------------//* Function Name       : Pause//* Object              : wait flash response//* Input Parameters    : none//* Output Parameters   : none//*----------------------------------------------------------------------------static void Pause(void){    int count;    for (count=0;count < TIME_OUT/10 ;count++)    {        /* Do nothing - just wait */    }}//* --------------------------- Export function -------------------------------//*----------------------------------------------------------------------------//* Function Name       : flash_at49_identify//* Object              : Get the device id//* Input Parameters    : <sart_addr> Flash base address//* Output Parameters   : device_code or 0xFFFF if bad manuf code//*----------------------------------------------------------------------------//*flash_word flash_at49_identify ( flash_word *base_addr )//* Beginint main(){	u_int size;	flash_word 		*base_addr;    flash_word      manuf_code ;    flash_word      device_code ;/*	led_on(0, LED_3);	led_on(0, LED_4);	led_on(0, LED_5);	led_on(0, LED_6);	led_on(0, LED_16);	led_on(0, LED_17);	led_on(0, LED_18);	led_on(0, LED_19);*/	led_on(1, LED_16);		//* Get base address	while( ((read_dbg_control() & R_BIT) != R_BIT) ); //* Wait a new data to read	base_addr = (flash_word *)read_dbg_data();	led_on(1, LED_17);    Pause();    //* Enter Software Product Identification Mode    *(base_addr + FLASH_SEQ_ADD1) = FLASH_CODE1;    *(base_addr + FLASH_SEQ_ADD2) = FLASH_CODE2;    *(base_addr + FLASH_SEQ_ADD1) = ID_IN_CODE;    //* Read Manufacturer and device code from the device    manuf_code  = *base_addr ;    device_code = *(base_addr + 1) ;    //* Exit Software Product Identification Mode    *(base_addr + FLASH_SEQ_ADD1) = FLASH_CODE1;    *(base_addr + FLASH_SEQ_ADD2) = FLASH_CODE2;    *(base_addr + FLASH_SEQ_ADD1) = ID_OUT_CODE;	led_on(1, LED_3);	//* Send the data	while( ((read_dbg_control() & W_BIT) == W_BIT) ); //* Wait a new data to write	write_dbg_data((u_int)manuf_code);		led_on(1, LED_4);	while( ((read_dbg_control() & W_BIT) == W_BIT) ); //* Wait a new data to write	write_dbg_data((u_int)device_code);	while(1){		led_on(1, LED_5);		for (size=0; size<300000;size++);		led_on(0, LED_5);		for (size=0; size<300000;size++);	}}//* End

⌨️ 快捷键说明

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