• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: 版主,你好!我没收到你的邮件,请再发一遍,谢谢!
#4
新會員
新會員


查看用戶資訊

發表於: 2006/3/30 16:55
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 版主,你好!我没收到你的邮件,请再发一遍,谢谢!
#3
新會員
新會員


查看用戶資訊
版主,请发一份邮件给我。we_you_me@sohu.com

thanks!

發表於: 2006/3/30 16:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 版主,你好!我没收到你的邮件,请再发一遍,谢谢!
#2
版主
版主


查看用戶資訊
已經再傳一次了,可能是檔案太大被過濾掉了吧!
現只傳部分EEPROM的程式。

/********************************************************************
*
*  Filename:   EEPROM.C
*  Purpose:    This file contains Data EEPROM erase/program/read
*              functions.
*
*********************************************************************/

/* header files */
#include "lab2.h"          /* lab 2 defines */
#include <ports.h>         /* ports peripheral library header file */
#include <uart.h>          /* uart peripheral library header file */
#include <p30f6014.h>      /* processor defines */

/* define the Data EEPROM constants */
/* these will be re-programmed during program execution */
const unsigned int _EEDATA() word_buffer[1024];
const 
unsigned int _EEDATA() row_buffer[1024];

/* globals - NOTE: these are located in RAM */
char sCRLF[] __attribute__ ((aligned)) = "rn";
char sTab[] __attribute__ ((aligned)) = "t";
char sWordRead[] __attribute__ ((aligned)) = "rnReading Word Array:rn";
char sRowRead[] __attribute__ ((aligned)) = "rnReading Row Array:rn";
char sEmpty[] __attribute__ ((aligned)) = "tEMPTY!rn";

/* externs */
extern unsigned new_row[];
extern unsigned row_offset_address;
extern unsigned word_offset_address;

/* funtion prototypes */
void EraseEE(void);
void ProgramEEWord (unsigned word);
void ProgramEERow (void);
void ReadEE(void);


/* source code */
/*************************************************************************
*                                                                         
*  Function:  EraseEE()
*  Arguments: none
*  Returns:   void

*  This function erases the entire EEPROM using the erase segment
*  operation.
*
**************************************************************************/
void EraseEE (void)   {
    
   
/* set the NVMCON for erasing all Data EEPROM */
   
NVMCON EE_ERS_ALL;
    
   
/* set the NVMADRU/NVMADR */
   
NVMADRU 0x7F;   // TBPLAG for EEPROM
   
NVMADR 0xF000;  // any EEPROM address okay
   
   /* start the erase */
   
UNLOCK_NVM_AND_PROGRAM;

   
/* wait until the erase completes */
   
while (!NVMCONbits.WR);
        
   }  
/* end EraseEE() */


/*************************************************************************
*                                                                         
*  Function:  ProgramEERow()
*  Arguments: none
*  Returns:   void
*
*  This function programs one row of the Data EEPROM.
*  The data programmed is from the new_row[] array.
*  The target row in the Data EEPROM is the present "row_offset_address".
*
**************************************************************************/
void ProgramEERow (void)   {

    
/* set the NVMCON for this programming */
    
NVMCON EE_PRG_ROW;

    
/* set the TBLPAG register... fixed for all Data EEPROM */
    
TBLPAG DATA_EEPROM_TBLPAG;

    
/* set the source register W6 to the desired word to write */
    
WREG6 = (unsigned) &new_row;

    
/* set the destination pointer W7 for programming */
    
WREG7 = (unsignedrow_offset_address;

    
/* load the 16 write latches */
    
LOAD_DATA_WRITE_LATCHES;   
   
    
/* now do the programming operation */
    
UNLOCK_NVM_AND_PROGRAM;
                     
    
/* wait until the erase completes, then verify WR is still clear */
    
while (NVMCONbits.WR);
    
    
/* set the row_offset_address to point to the next row */
    
row_offset_address += 2*NUM_EE_WORDS_PER_ROW;
   
}  
/* end ProgramEERow() */


/*************************************************************************
*                                                                         
*  Function:  ProgramEEWord()
*  Arguments: word, the data value to program
*  Returns:   void
*
*  This function programs the specified word to the Data EEPROM.
*  The target location is the present "word_offset_address".
*
**************************************************************************/
void ProgramEEWord (unsigned word)   {

    
/* set the NVMCON for this programming */
    
NVMCON EE_PRG_WORD;

    
/* set the TBLPAG register... fixed for all Data EEPROM */
    
TBLPAG DATA_EEPROM_TBLPAG;

    
/* set the source register W6 to the desired word to write */
    
WREG6 word;

    
/* set the destination pointer W7 for programming */
    
WREG7 = (unsignedword_offset_address;
   
    
/* load the one write latch! */
    
asm ("tblwtl.w w6, [w7]  ; write the 16-bit word");
   
    
/* now do the programming operation */
    
UNLOCK_NVM_AND_PROGRAM;
                     
    
/* wait until the programming completes */
    
while (NVMCONbits.WR);

    
/* point to the next location of Data EEPROM */
    
word_offset_address += 2;
   
}  
/* end ProgramEEWord() */


/*************************************************************************
*                                                                         
*  Function:  ReadEE()
*  Arguments: none
*  Returns:   void
*
*  This function reads the two halves of the Data EEPROM and outputs
*  the data to the UART.  Erased locations are not written to the UART. 
*
**************************************************************************/
void ReadEE (void)
{
   
int ppage_shadow;
   
unsigned iu;

   
/* save the PSVPAG */   
   
page_shadow PSVPAG;   

   
/* set the PSVPAG for Data EEPROM */
   
CORCONbits.PSV 1;
   
PSVPAG 0xFF;

   
/* print a message */
   
putsUART2 ((int*) sWordRead);

   
/* read the first half - which was programmed by word */
   
0;
   
   if ( (
word_buffer[u] == 0xFFFF) )
   {
      
/* Data EEPROM half is empty! */
      
putsUART2 ((int*) sEmpty);      
   }
   else
   {   
      
/* print a tab */
      
putsUART2 ((int*) sTab);

      while (
word_buffer[u] != 0xFFFF
      {
         while (
BusyUART2());
         
WriteUART2 (word_buffer[u]);
         
+= 1;
         
         
/* after 16 words, print a CR-LF */
         
if (!(u%16)) {
            
/* print a CR-LF and tab */
            
putsUART2 ((int*) sCRLF);
            
putsUART2 ((int*) sTab);
            }
      }  
/* end while () */
   
}  /* end else */
   
   /* read the last half - which was programmed by row */
   /* print a message */
   
putsUART2 ((int*) sRowRead);
   
0;
   if ( (
row_buffer[u] == 0xFFFF) )
   {
      
/* Data EEPROM half is empty! */
      
putsUART2 ((int*) sEmpty);      
   }
   else
   {   
      while (
row_buffer[u] != 0xFFFF)
      {
         
/* print a tab */
         
putsUART2 ((int*) sTab);
   
         
/* we have a programmed row - dump it to UART */
         
for (i=0i<16i++)
         {
            while (
BusyUART2());
            
WriteUART2 (row_buffer[u+i]);
        
         }  
/* end for (i) */
      
         /* add a CR-LF */
         
putsUART2 ((int*) sCRLF);
      
         
/* bump the row */
         
+= 16;
            
      }  
/* end while () */
   
}  /* end else */

   /* restore the PSVPAG */
   
PSVPAG page_shadow;
   
}  
/* end ReadEE() */

發表於: 2006/3/23 15:25
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


版主,你好!我没收到你的邮件,请再发一遍,谢谢!
#1
新會員
新會員


查看用戶資訊
我发的主题是 “版主,你好!我有关于DSPIC30F6014读写内部E2PROM的问题请教,因项目着急,请尽快答复,谢谢!”
我的邮箱是“gzsl1234@163.com"

發表於: 2006/3/23 12:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------