• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: pic 18 eeprom 前置參數設定
#7
版主
版主


查看用戶資訊
ak47,

EEPROM 的設定值是在做燒錄時就直接燒到 EEPROM 裡,此值隨時隨地都存在的,而且開機後也不需要做寫入或設定初始值的動作。

發表於: 2008/1/23 12:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic 18 eeprom 前置參數設定
#6
高級會員
高級會員


查看用戶資訊
如此的宣告等於每次POWER ON時,即給EEPROM一些固定初值,若是這樣不如放在RAM就好,R/W也比較快。
我以為EEPROM的目的是要讓mcu在下次POWER ON時可保留OFF前最後的資料。

發表於: 2008/1/23 11:55
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic 18 eeprom 前置參數設定
#5
中級會員
中級會員


查看用戶資訊
謝謝各位大大先去測試一下

發表於: 2008/1/14 13:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic 18 eeprom 前置參數設定
#4
資深會員
資深會員


查看用戶資訊
如果一定要存放在EEPROM某位址的話
可修改一下

#pragma romdata EEPROM_romdata=0xF00010 //指定開始位址
rom unsigned char EE_init[]= {0x00,0x12,0x60,0x01,0x30};
#pragma romdata

位址範圍須參考你的.lkr檔

發表於: 2008/1/14 11:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic 18 eeprom 前置參數設定
#3
版主
版主


查看用戶資訊
#pragma romdata EEDATA
rom unsigned char EE_Dara1[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};
rom unsigned char EE_Data2[] = {0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
rom unsigned char EE_Data3[] = {'H','i','-','T','e','c','h',0x00,};
rom unsigned int EE_Data4 0xAAA0,EEdata 0xAAA2;
rom unsigned long EE_Data6 0x61626364;
#pragma romdata

說明一下,可以這樣做的原因是因為在 LKR 檔裡有 EEDATA 節區的宣告:
CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED
SECTION NAME=EEDATA ROM=eedata

發表於: 2008/1/14 11:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic 18 eeprom 前置參數設定
#2
版主
版主


查看用戶資訊
這裡有範例:
****************************************************************
//   This file is a example code for the Internal EEDATA access  *
//   on the PICmicro PIC18F452.                                   *  
//                                                               *
//   How about userful in the example code:               * 
//      1. Know the how to define the EEDATA using C18          *        
//    2. Read the Internal EEDATA using C code         *
//    3. Write data into the Internal EEDATA              *
//                                                               *
//****************************************************************
//                                                               *
//    Filename:EEDATA for 452_C.C                                   *
//    Date: 25 March 2005                                        *
//    File Version: v1.0                                         *
//                                                               *
//    Author: Richard Yang                                       *
//    Company:  Microchip Technology                             *
//                                                               * 
//                                                               *
//****************************************************************
//                                                               *
//    Files required: MPLAB IDE v7.0                             *
//                    MPLAB C18 v2.30                            *
//                                                               *
//****************************************************************

#include <p18f452.h>        // processor if/def file

//**********************************
//* Function Prototype Declaration
//**********************************
void EE_Write (unsigned charunsigned char);
unsigned char EE_Read (unsigned char);

// ================================================================
// ****     The Configuration was defined in the DS51537A      ****
// ****     DS51537A : PIC18 Configuration Settings Addendum   ****
//
//  MPLAB C18 v2.40 (or higher) version has defined the Configuration
//  Setting in the DS51537A, you can refer with the document for 
//  setting the Configuretion data using #progma config directive

#pragma config OSC = HS, OSCS=OFF
#pragma config PWRT = ON, BOR = ON, BORV = 42 
#pragma config WDT = OFF, CCP2MUX = OFF, STVR = OFF 
#pragma config LVP = OFF, DEBUG = ON
#pragma config CP0 = OFF, CP2 = OFF, CP3 = OFF
#pragma config CPB = OFF, CPD = OFF
 

// *****     Define byte data into the Internal EEPROM    *****
//
#pragma romdata EEDATA
rom unsigned char EE_Dara1[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};
rom unsigned char EE_Data2[] = {0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
rom unsigned char EE_Data3[] = {'H','i','-','T','e','c','h',0x00,};
rom unsigned int EE_Data4 0xAAA0,EEdata 0xAAA2;
rom unsigned long EE_Data6 0x61626364;
#pragma romdata


// *****     RAM variable Declaration   *****
#pragma udata access EE_Array
near unsigned char EE_Read_Buffer[64];
#pragma udata

char i;
unsigned char EE_WR_ASCII='a';


void main (void)
{

    for (
i=0x20;i<0x40;i++)            // Write 32 bytes to EEPROM with start address at 0x20
    
{
        
EE_Write(i,EE_WR_ASCII);    // Write a byte to EEPROM
        
EE_WR_ASCII++;            // Generate a next ASCII code
    
}

    for (
i=0i<64;i++)            // Read 64 bytes from EEPROM with start address 0x00
    
{
        
EE_Read_Buffer[i] = EE_Read(i); // Read a byte form EEPROM
    
}

    while(
1);
}
void EE_Write (unsigned char EE_Addressunsigned char EE_Data)
{
    
PIR2bits.EEIF 0;
    
EEADR EE_Address;
    
EEDATA EE_Data;
    
EECON1bits.EEPGD 0;
    
EECON1bits.CFGS 0;
    
EECON1bits.WREN 1;
    
INTCONbits.GIE 0;
_asm
    MOVLW    0X55
    MOVWF    EECON2
,0
    MOVLW    0XAA
    MOVWF    EECON2
,0
    BSF        EECON1
,1,0
_endasm
    INTCONbits
.GIE 1;
    while (!
PIR2bits.EEIF);
    
PIR2bits.EEIF 0;
    
EECON1bits.WREN 0;
}
unsigned char EE_Read (unsigned char EE_Address)
{
    
EEADR EE_Address;
    
EECON1bits.EEPGD 0;
    
EECON1bits.CFGS 0;
    
EECON1bits.RD 1;
    return 
EEDATA;
}

發表於: 2008/1/14 11:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


pic 18 eeprom 前置參數設定
#1
中級會員
中級會員


查看用戶資訊
不知道c18 有沒有在程式program時將pic 18 eeprom特定位址設定為所需特定數字的指令

發表於: 2008/1/14 11:24
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... ]

教育訓練中心

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