• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






Re: [求助] PIC18F6722 EEPROM問題~~
#3
高級會員
高級會員


查看用戶資訊
謝謝回覆!!
寫入有BIT (WRERR or EEIF)可以判斷, 讀取找不到BIT.

另外, 寫入也有問題, 有時會當在迴圈跳不出來, 程式如下:


void EE_Write (unsigned char EE_Write_Address_Hi,unsigned char EE_Write_Address , unsigned char EE_Write_Data_Byte)
{
PIR2bits.EEIF=0;
EEADRH=0;
EEADRH = (Address & 0xFF00)>>8;
EEADR = Address & 0x00FF;
EEDATA=bData;
EECON1bits.EEPGD=0; // Acess Data EEPROM Memory
EECON1bits.CFGS=0; // Acess Fash Program or Data EEPROM Memory
EECON1bits.WREN=1;
INTCONbits.GIE=0; // Hi Priority
// Lowi Priority
_asm
movlw 0x55
movwf EECON2,0
movlw 0xAA
movwf EECON2,0
bsf EECON1,1,0
nop
_endasm

INTCONbits.GIE=1; // Hi Priority
while(!PIR2bits.EEIF);
PIR2bits.EEIF=0;
EECON1bits.WREN=0;
}

發表於: 2007/9/10 9:05
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: [求助] PIC18F6722 EEPROM問題~~
#2
資深會員
資深會員


查看用戶資訊
你好像沒有等EEPROM讀取完成,就把EEDATA的值傳回來了,應該要先判斷EEPROM是否讀取完成,有一個BIT可以判斷.

unsigned char EE_Read (unsigned char EE_Read_Address_Hi,unsigned char EE_Read_Address)
{
    
EEADRH=0;
    
EEADRH=EE_Read_Address_Hi;
    
EEADR=EE_Read_Address;
    
EECON1bits.EEPGD=0;
    
EECON1bits.CFGS=0;
    
EECON1bits.RD=1;
    return 
EEDATA;
}

發表於: 2007/9/8 2:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


[求助] PIC18F6722 EEPROM問題~~
#1
高級會員
高級會員


查看用戶資訊
讀取EEPROM會發生錯誤, 程式會停在count2 = count2 + 1, count1不一定(Random), 程式測試如下:
#define            RS232TxMax    105

void main(void)
{
    ...
    while(
1)
    {
        ...
        
Test_RS232();

    }
}

void Test_RS232(void)
{
    
unsigned char i;
    
unsigned short Address;

    
count1 count1+1;
    for (
i=0;i<RS232TxMax;i++)    
    {
        
test_buf[i] = 0;
                
RS232TxBuf[i]=0
    
}
                
    
Address RX_CH1_ADDR;// + i * 0x10;    // RX_CH1_ADDR = 0x10
    
for (i=0;i<16;i++)
    {
        
EE_Addr=(Address+i) & 0x00FF;
        
EE_Addr_Hi=((Address+i) & 0xFF00)>>8;    
        
EE_Read(EE_Addr_Hi,EE_Addr);
        
test_buf[i]=EEDATA;    
    }
    for (
i=0;i<16;i++)
    {
        
EE_Addr=(Address+i) & 0x00FF;
        
EE_Addr_Hi=((Address+i) & 0xFF00)>>8;    
        
EE_Read(EE_Addr_Hi,EE_Addr);
        
RS232TxBuf[i]=EEDATA;    
    }
                
    for (
i=0;i<16;i++)
    {
        if (
test_buf[i] != RS232TxBuf[i])
            
count2 count2 1;    <----------
    }
    if ((
count1 == 1000) || (count2==5))
        
count3=1;
}

unsigned char EE_Read (unsigned char EE_Read_Address_Hi,unsigned char EE_Read_Address)
{
    
EEADRH=0;
    
EEADRH=EE_Read_Address_Hi;
    
EEADR=EE_Read_Address;
    
EECON1bits.EEPGD=0;
    
EECON1bits.CFGS=0;
    
EECON1bits.RD=1;
    return 
EEDATA;
}

謝謝回覆~~

發表於: 2007/9/7 16:31
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... ]

教育訓練中心

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