• 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: 請問pic18f24j10與eeprom 93c46的spi溝通問題
#3
新會員
新會員


查看用戶資訊
謝謝這位大大的幫忙!!我試了之後SPI方面看起來是有符合規格可是我都一直讀到錯的值 而且有方法可以測試寫和擦除是成功的嗎?
就是不能確定東西有沒有寫進去 而且他D0回給我的波形是一個遞減的波形 很奇怪~~~我附上我讀取的副程式能幫我看看嗎?謝謝!! (93c46a)
unsigned char ReadData(unsigned char Addr) {
unsigned char LoopCnt;
unsigned char Data;

PORTD |= PinCS;

PORTD &= ~PinCLK;
for(LoopCnt = 0;LoopCnt < 10;LoopCnt++) {
if(Addr & 0x80)
PORTD |= PinDO;
else PORTD &= ~PinDO;


PORTD |= PinCLK;
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
PORTD &= ~PinCLK;
Addr <<= 1;
}


PORTD &= ~PinCS;


for(LoopCnt = 0;LoopCnt < 8;LoopCnt++) {
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
PORTD |= PinCLK;
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
if(PORTD & PinDI) Data |= 0x01;
Data <<= 1;
PORTD &= ~PinCLK;
}
PORTD &= ~PinCS;

return Data;
}



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


Re: 請問pic18f24j10與eeprom 93c46的spi溝通問題
#2
資深會員
資深會員


查看用戶資訊
雖然不是PIC用的,但大同小異,自己改一下吧.
架構是對的,但信號的正負和你要的不同...
#define    PinCS    0x01
#define    PinCLK    0x02
#define    PinDO    0x04
#define    PinDI    0x08

void WriteData(BYTE AddrWORD Data) {
    
BYTE    LoopCnt;
    
    
PRT0DR |= PinCS;
    
PRT0DR &= ~PinCLK;
    for(
LoopCnt 0;LoopCnt 8;LoopCnt++) {
        if(
Addr 0x80PRT0DR |= PinDO;
        else 
PRT0DR &= ~PinDO;
        
asm("nop");
        
asm("nop");
        
PRT0DR |= PinCLK;
        
asm("nop");
        
asm("nop");
        
asm("nop");
        
PRT0DR &= ~PinCLK;
        
Addr <<= 1;
    }
    
    for(
LoopCnt 0;LoopCnt 16;LoopCnt++) {
        if(
Data 0x80PRT0DR |= PinDO;
        else 
PRT0DR &= ~PinDO;
        
asm("nop");
        
asm("nop");
        
PRT0DR |= PinCLK;
        
asm("nop");
        
asm("nop");
        
asm("nop");
        
PRT0DR &= ~PinCLK;
        
Data <<= 1;
    }
    
PRT0DR &= ~PinCS;
}

WORD ReadData(BYTE Addr) {
    
BYTE    LoopCnt;
    
WORD    Data;
        
    
PRT0DR |= PinCS;
    
PRT0DR &= ~PinCLK;
    for(
LoopCnt 0;LoopCnt 8;LoopCnt++) {
        if(
Addr 0x80PRT0DR |= PinDO;
        else 
PRT0DR &= ~PinDO;
        
asm("nop");
        
asm("nop");
        
PRT0DR |= PinCLK;
        
asm("nop");
        
asm("nop");
        
asm("nop");
        
PRT0DR &= ~PinCLK;
        
Addr <<= 1;
    }
    
    for(
LoopCnt 0;LoopCnt 16;LoopCnt++) {
        
asm("nop");
        
asm("nop");
        
PRT0DR |= PinCLK;
        
asm("nop");
        
asm("nop");
        
asm("nop");
        if(
PRT0DR PinDIData |= 0x01;
        
Data <<= 1;
        
PRT0DR &= ~PinCLK;
    }
    
PRT0DR &= ~PinCS;
    
    return    
Data;    
}

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


請問pic18f24j10與eeprom 93c46的spi溝通問題
#1
新會員
新會員


查看用戶資訊
請各位大大幫幫忙!!
我是用PIC18想外接一顆93C46的EEPROM
但是在SPI溝通方面我發現他的SCK要有連續18個週期而且
我的SSPBUF只有8位元它的操作碼加位址要10位元
所以我使用它內建的SPI模組寫不出來
請問有大大用C解決過這問題的嗎?
能否給我範例程式做參考 謝謝!!

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

教育訓練中心

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