• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
:::


Browsing this Thread:   1 Anonymous Users






Re: eeprom的寫入問題
#5
版主
版主


查看用戶資訊
是的,沒用到 SPI 中斷,SPIxIE 就要設為 0。

發表於: 2009/9/4 17:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: eeprom的寫入問題
#4
新會員
新會員


查看用戶資訊
還有一個問題,我沒有用到spi的中斷,是不是可以不用設置spi的中斷寄存器

發表於: 2009/9/4 16:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: eeprom的寫入問題
#3
新會員
新會員


查看用戶資訊
不是我自己寫的,是microchip圖形庫中的程式,最新1.75b
demo程式中EEPROM.c裏面的 謝謝你的連接 我先換一下試試

發表於: 2009/9/4 16:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: eeprom的寫入問題
#2
版主
版主


查看用戶資訊
你的SPI函數是自己寫的嗎? Microchip C30 的 SPI 函數跟你的不一樣,請參考一下 SPI Library:
C:\Program Files\Microchip\MPLAB C30\docs\periph_lib\dsPIC30F_dsPIC33F_PIC24H_SPI_Help.htm

參考底下的範例 :
http://www.microchip.com.tw/modules/w ... lefile.php?cid=12&lid=397

或裡面的 SPI 章節:
http://www.microchip.com.tw/modules/w ... glefile.php?cid=4&lid=229

發表於: 2009/9/4 13:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


eeprom的寫入問題
#1
新會員
新會員


查看用戶資訊
各為看下我的問題,再寫入eeprom的時候會死機,用ice仿真到的是SPIPut()裏面SPI2STATbits.SPITBF不會硬件自動清零。導致死循環,程序SPIPut()寫入第一個命令時沒問題,寫入第二個的時候就會出錯SPITBF一直是1,不會清零

#define EEPROM_PAGE_SIZE (unsigned)64
#define EEPROM_PAGE_MASK (unsigned)0x003f
#define EEPROM_CMD_READ (unsigned)0x03
#define EEPROM_CMD_WRITE (unsigned)0x02
#define EEPROM_CMD_WRDI (unsigned)0x04
#define EEPROM_CMD_WREN (unsigned)0x06
#define EEPROM_CMD_RDSR (unsigned)0x05
#define EEPROM_CMD_WRSR (unsigned)0x01

#define EEPROMSSLow() EEPROM_SS_PORT=0;
#define EEPROMSSHigh() EEPROM_SS_PORT=1;

void EEPROMWriteByte(BYTE data, WORD address)
{
EEPROMWriteEnable();
EEPROMSSLow();

SPIPut(EEPROM_CMD_WRITE);
SPIGet();

SPIPut(((WORD_VAL)address).v[1]);
SPIGet();

SPIPut(((WORD_VAL)address).v[0]);
SPIGet();

SPIPut(data);
SPIGet();

EEPROMSSHigh();

// Wait for write end
while(EEPROMReadStatus().Bits.WIP);
}

void SPIPut(BYTE data)
{
// Wait for free buffer
while(SPI2STATbits.SPITBF);
SPI2BUF = data;
// Wait for a data byte reception
while(!SPI2STATbits.SPIRBF);

}

void EEPROMWriteEnable(){
EEPROMSSLow();
SPIPut(EEPROM_CMD_WREN);
SPIGet();
EEPROMSSHigh();
}

發表於: 2009/9/4 10:11
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... ]

教育訓練中心

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