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


Browsing this Thread:   1 Anonymous Users






Re: 關於C18是否有支援內建EEPROM之函數
#6
高級會員
高級會員


查看用戶資訊
感謝各位大大的幫忙

小弟感激不盡

發表於: 2005/4/11 17:54
人生最長久的擁有是珍惜 但是大都在失去後才發現
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於C18是否有支援內建EEPROM之函數
#5
資深會員
資深會員


查看用戶資訊

CCS 有 value = read_eeprom (address) 和
write_eeprom (address, value)

試看看吧 http://www.ccsinfo.com/demo.shtml

簡單好用,適用於 16F 和 18F 全系列

更不用去依據特定的晶片改什麼 LKR 檔 ... C18 該學學才對

多喝水喔

發表於: 2005/4/11 10:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於C18是否有支援內建EEPROM之函數
#4
高級會員
高級會員


查看用戶資訊
可以麻煩您寄給我ㄧ份嗎,謝謝~~~
E-mail : abcxyz12356@yahoo.com.tw

發表於: 2005/4/10 21:32
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於C18是否有支援內建EEPROM之函數
#3
高級會員
高級會員


查看用戶資訊
可以麻煩您寄給我ㄧ份嗎,謝謝~~~
E-mail : abcxyz12356@yahoo.com.tw

發表於: 2005/4/10 21:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於C18是否有支援內建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;
}


到了這裡還是要修改 LKR 檔案給 EEDATA 的節區宣告:

// Sample ICD2 linker script for the PIC18F452 processor
LIBPATH .

FILES c018i.o
FILES clib
.lib
FILES p18f452
.lib

CODEPAGE   NAME
=vectors    START=0x0            END=0x29           PROTECTED
CODEPAGE   NAME=page       START=0x2A           END=0x7DBF
CODEPAGE   NAME
=debug      START=0x7DC0         END=0x7FFF         PROTECTED
CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED

ACCESSBANK NAME=accessram  START=0x0            END=0x7F
DATABANK   NAME
=gpr0       START=0x80           END=0xFF
DATABANK   NAME
=gpr1       START=0x100          END=0x1FF
DATABANK   NAME
=gpr2       START=0x200          END=0x2FF
DATABANK   NAME
=gpr3       START=0x300          END=0x3FF
DATABANK   NAME
=gpr4       START=0x400          END=0x4FF
DATABANK   NAME
=gpr5       START=0x500          END=0x5F3
DATABANK   NAME
=dbgspr     START=0x5F4          END=0x5FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED

SECTION    NAME=CONFIG     ROM=config
SECTION       NAME
=EEDATA     ROM=eedata

STACK SIZE
=0x100 RAM=gpr4

發表於: 2005/4/10 15:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於C18是否有支援內建EEPROM之函數
#1
高級會員
高級會員


查看用戶資訊
請問各位大大

C18函數是否有支援內建的EEPROM

因為我翻了一下Library的書, 內文提到的EEPROM函數都是以
I2C為主, 那要用PIC18系列的內部EEPROM要如何做?

請各位大大指導

發表於: 2005/4/10 10:13
人生最長久的擁有是珍惜 但是大都在失去後才發現
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... ]

教育訓練中心

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