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

📄 amd parallel flash programmer for 21369.asm

📁 ADI 公司的DSP ADSP21369 EZ-KIT LITE开发板的全部源代码
💻 ASM
字号:
//**********************************************************************************************************************************
//**********************************************************************************************************************************
//"AMD Parallel Flash Programmer.asm"   7/2005 DSP Applications Engineering
//This program is intended for the AMD 8-bit 1M parallel flash
//found on the ADSP-21369 Ez-Kit.

//The subroutines will:
//  -FLASH_FILE_SIZE:   -check to see that the buffer 'my_file' is not too large to fit in the 1Mx8 flash
//  -FLASH_RESET:       -issue the flash reset command
//  -SECTOR_ERASE:      -calculate the number of sector needed to hold the data and erase accordingly (and verify erasure)
//  -PROGRAM_FLASH:     -program the flash with the data/code in my_file and check for write cmd completion after each byte
//  -VERIFY_FLASH:      -verify the contents of the flash with the values in 'my_file',
//

//This example is intended to provide a starting point to be tailored to fit specific needs.

//To program boot loader code into the flash, use the Loader in VisualDSP++ 3.0 and generate a .ldr file with the following options:
//      -Width: 16
//      -Boot Type: Parallel Port (prom)
//      -Format:    Include
//**********************************************************************************************************************************
//**********************************************************************************************************************************

#include <def21369.h>

// The following definition allows the SRU macro to check for errors. Once the routings have
// been verified, this definition can be removed to save some program memory space.
// The preprocessor will issue a warning stating this when using the SRU macro without this
// definition
#define SRUDEBUG  // Check SRU Routings for errors.
#include <SRU.h>

#include "flashprogrammer.h"

.global _main,TEST_FAIL;
.extern SECTOR_ERASE;
.extern FLASH_RESET;
.extern PROGRAM_FLASH;
.extern VERIFY_FLASH;

// 32-bit data section
.section/dm seg_dmda;
.var External_Byte_Address;
.var External_Sector_Address[]=0;
.var Data_Byte;
.var Word_To_Write[6];
.var Word_Read_In[2];
.global Word_To_Write,Word_Read_In, Data_Byte,External_Sector_Address,External_Byte_Address;

// 16-bit data section
.section/dm seg_dm16;                   //short-word address space
.var my_file[] = "Ezkit.ldr";          //16-bit loader file
.var read_back;                         //buffer to read the programmed data to internal memory
.global my_file, read_back;

// --------------------------------------------------------------------------------------------
// Main Program Section
.section/pm seg_pmco;
_main:

    // Set up the AMI for Bank 1
    // 8-bit bus width
    // 23 Wait States
    // Packing Disabled
    ustat1 = AMIEN|BW8|WS23|PKDIS|AMIFLSH;
    dm(AMICTL1) = ustat1;

    bit set FLAGS FLG4O|FLG5O|FLG6O|FLG7O; //Sets FLAGs as outputs

    // Initialize the DPI to use the LEDs
    CALL _initSRU;
        bit set FLAGS FLG4;     //LED1 lit at start

    // Erase the necessary amount of space
    call SETUP;
        bit set FLAGS FLG5;     //LED2 lit after erase command

    // Program the flash
    call PROGRAM_FLASH;
        bit set FLAGS FLG6;     //LED3 lit after flash programmed

    // Verify the data that was just programmed
    call VERIFY_FLASH;
        bit set FLAGS FLG7;    //LED4 lit after verified successfully

_main.end:
      jump DONE;

// --------------------------------------------------------------------------------------------
// Setup Resets the flash, Checks the file size, and erases the needed amount of flash space
SETUP:
    call FLASH_FILE_SIZE;   //be sure the data will fit in the flash
    call FLASH_RESET;       //issue the flash reset command
    call SECTOR_ERASE;      //erases proper # of sectors and verifies erasure
    rts;

// --------------------------------------------------------------------------------------------
// Check the size of the file and compare against max size
FLASH_FILE_SIZE:
    r5 = length(my_file)*BYTES;         // read the # of bytes to program
    r6 = 1024000;                       // size of flash is 1Mx8
    comp (r5, r6);
    if ge jump TEST_FAIL;               // verify file will fit in flash
    rts;

// --------------------------------------------------------------------------------------------
// Initialize the DPI to use the Flags
_initSRU:

SRU2(FLAG4_O,DPI_PB06_I);   // Connects Flag4 output to DPI pin 6 connected to LED1 on the Ez-kit
SRU2(HIGH,DPI_PBEN06_I);    // enables DPI pin6 as input
SRU2(FLAG5_O,DPI_PB07_I);    // Connects Flag5 output to DPI pin 7 connected to LED2 on the Ez-kit
SRU2(HIGH,DPI_PBEN07_I);     // enables DPI pin 7 as input
SRU2(FLAG6_O,DPI_PB08_I);    // Connects Flag6 output to DPI pin 8 connected to LED3 on the Ez-kit
SRU2(HIGH,DPI_PBEN08_I);     // enables DPI pin 8 as input
SRU2(FLAG7_O,DPI_PB13_I);    // Connects Flag7 output to DPI pin 13 connected to LED4 on the Ez-kit
SRU2(HIGH,DPI_PBEN13_I);     // enables DPI pin 8 as input

_initSRU.end: rts;

// --------------------------------------------------------------------------------------------
// Wait here after programming is successful, toggle all of the LEDs forever
DONE:

   ustat1 = 0;
   dm(AMICTL1) = ustat1;  //disables the AMICTL


   do DONE_LOOP until forever;

   bit tgl FLAGS FLG4|FLG5|FLG6|FLG7;  // toggles LED1, LED2, LED3, LED4

   lcntr=0x900000; do Wait_Loop until lce;
   nop;
   Wait_Loop: nop;

DONE_LOOP:
    nop;

// --------------------------------------------------------------------------------------------
// Wait here if an error was detected
TEST_FAIL:
    nop;
    jump TEST_FAIL;
TEST_FAIL.END:

⌨️ 快捷键说明

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