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


Browsing this Thread:   1 Anonymous Users






Re: C18 SPI 介面使用設定的問題
#2
高級會員
高級會員


查看用戶資訊
找到問題了,因為我用MPLAB SIM 去模擬,所以不會真正發送資料,使得BF一直為0。
最近剛好發現 MPLAB SIM simulation 有軟体 LA 可以用就很高興的拿來用,i/o的做動還蠻正常的,用到SPI一直看不到資料發送誤以為設定一直是不正確的,一開始直接用ICD2跑就不會有這種問題了(○_o汗)....

發表於: 2006/11/15 15:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


C18 SPI 介面使用設定的問題
#1
高級會員
高級會員


查看用戶資訊
參考了一些source code ,好像也沒特別的設定,不過我用Mplab sim 發現sck sdo 都沒反應,WriteSpi會一直停在等SSPSTATbits.BF flag ,請問是那邊有設定問題呢?


void main(void){
   
init_io();
   
init_timer();
   
OpenSPI(SPI_FOSC_64MODE_11SMPMID);
   
Nop();
   while(
1){
       
WriteSPI(0xaa);
   }
}

void init_io(void){

    
PORTA=0x3f;
    
LATA=0x3f;
    
TRISA=0x00;

    
PORTB=0x00;
    
LATB=0x00;
    
TRISB=0xff;

    
PORTC=0x00;
    
LATC=0x00;
    
TRISC=0x10;

    
PORTD=0x00;
    
LATD=0x00;
    
TRISD=0x00;

    
PORTE=0x00;
    
LATE=0x00;
    
TRISE=0x00;

    
PORTF=0x00;
    
LATF=0x02;
    
TRISF=0xcd;

    
PORTG=0X00;
    
LATG=0x18;
    
TRISG=0X00;

    
PORTH=0X00;
    
LATH=0x0C;
    
TRISH=0X03;

    
PORTJ=0x00;
    
LATJ=0x00;
    
TRISJ=0x01;

}

void init_timer(void)
{
    
_asm
        MOVLW 0x1f    
//B'00011111'        //DISABLE PRIORITY LEVEL
        
MOVWF RCON,0
        
//bit 7 IPEN:0 = Disable priority levels on interrupts (PIC16CXXX Compatibility mode)
        //bit 4 RI:1 = The RESET instruction was not executed
        //bit 3 TO:1 = After power-up, CLRWDT instruction or SLEEP instruction
        //bit 2 PD:1 = After power-up or by the CLRWDT instruction
        //bit 1 POR:1 = A Power-on Reset has not occurred   POR:0 A Power-on Reset occurred
        //bit 0 BOR:1 = A Brown-out Reset has not occurred  BOR:0 A Brown-out Reset occurred

        
MOVLW 0x80    //B'10000000'        //DISABLE EXTERNAL BUS
        
MOVWF MEMCON,0
        
//bit 7 EBDIS:1 = External system bus disabled, all external bus drivers are mapped as I/O ports

        
MOVLW 0xe0    //B'11100000'        //ENABLE UNMASKED PERIPHERAL INTERRUPT
        
MOVWF INTCON,0        //DEFAULT DISABLE ALL INTERRUPT

        
MOVLW 0xc0    //B'11000011'
        
MOVWF T0CON,0

        MOVLW 0x0f    
//B'00001111'        //A/D PORT CONFIG DIGITAL I/O
        
MOVWF ADCON1,0

        MOVLW 0x07    
//B'00000111'        //COMPARATOR OFF
        
MOVWF CMCON,0
    _endasm

}

發表於: 2006/11/13 13:43
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... ]

教育訓練中心

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