• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: PIC18F27Q43 client mode SDO 輸出訊號異常問題
#4
版主
版主


查看用戶資訊
PIC18F 有兩種中斷模式: "開啟中斷優先權的設定: RCONbits.IPEN=1;"

1. PIC18F 標準中斷方式,有分高優先權及低優先權中斷。除了開啟相對應的中斷外,還需要設定該中斷的 IP 位元為高優先權 (=1) 或低優先權(=0)。其說明如下:

// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts

// Use the following macros to:

// Enable high priority global interrupts
//INTERRUPT_GlobalInterruptHighEnable();

// Enable low priority global interrupts.
//INTERRUPT_GlobalInterruptLowEnable();

2. 如果是要相容於 PIC16F 的中斷模式則須設定 "RCONbits.IPEN=0"
這時中斷會有一個 Global Interrupt Enable bit (GIE=1) 及周邊中斷控制位元 (PEIE=1) ,所以有兩個位元要設定,參考底下方塊圖:

// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable(); 移除註解

// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable(); 移除註解

請將程式裡的 PEIE 註解移除就可以產生中斷了。

Attach file:



jpg  擷取.JPG (61.38 KB)
16_606c0345c384d.jpg 717X533 px

發表於: 2021/4/6 14:43
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC18F27Q43 client mode SDO 輸出訊號異常問題
#3
新會員
新會員


查看用戶資訊
Hi Ryang
RC0 & RC2設定漏掉沒有貼過來,設定為:
RC0PPS = 0x32; //RC0->SPI1:SDO1;
SPI1SSPPS = 0x12; //RC2->SPI1:SS1;

在main底下的INTERRUPT_GlobalInterruptEnable();有打開

void SPI1_Initialize(void)
{
SPI1CON0 = 0x00;
SPI1CON1 = 0x04;
SPI1CON2 = 0x07;
SPI1CLK = 0x01;
SPI1BAUD = 0x00;
TRISCbits.TRISC3 = 1;
PIE3bits.SPI1RXIE = 1;
SPI1_SetRxInterruptHandler(SPI1_DefaultRxHandler);
}


有檢查到沒有資料回傳原因是沒有進入SPI1_DefaultRxHandler(),在SPI1_DefaultRxHandler()內放IO Toggle,發現並沒有動作。想請問目前這樣的設定值是否仍有錯誤造成不會進入SPI1_DefaultRxHandler()。謝謝。

發表於: 2021/4/6 13:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC18F27Q43 client mode SDO 輸出訊號異常問題
#2
版主
版主


查看用戶資訊
剛看了 PIC18F27Q43 的 Data Sheet 裡的 Page 16 有關對 SDO1 腳位的使用說明。
SCK1 --> RC3 (設定成輸入腳功能)
SDI1 --> RC4 (設定成輸入腳功能)
SDO1 --> RC0 ??
SDO1 的輸出腳須經由 PPS 選定腳位並設定成輸出功能,這點在程式裡沒有看到。請檢查一下 SPI1 的腳位設定及輸出入功能。

Data Sheet 的註記:
2. All output signals shown in this row are PPS remappable. These signals may be mapped to output onto one of several PORTx pin options as described in the peripheral output selection table.

發表於: 2021/4/6 11:17
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC18F27Q43 client mode SDO 輸出訊號異常問題
#1
新會員
新會員


查看用戶資訊
MPLAB X IDE v5.40
XC8(v2.31)
============================
設定如下
void SPI1_Initialize(void)
{
SPI1CON0 = 0x00;
SPI1CON1 = 0x44;
SPI1CON2 = 0x07;
SPI1CLK = 0x01;
SPI1BAUD = 0x00;
TRISCbits.TRISC3 = 1;
PIE3bits.SPI1RXIE = 1;
SPI1_SetRxInterruptHandler(SPI1_DefaultRxHandler);
SPI1CON0bits.EN = 1;
}


在MCC產生的SPI1_DefaultRxHandler內單傳做資料接收(只是單純不讓FIFO滿,不做資料判讀),並同時固定丟出0xAA,做功能測試。

void SPI1_DefaultRxHandler(void)
{
rxB = SPI1RXB;
SPI1TXB = 0xAA;
}


master端一直無法正確收到0xAA,將波形勾示波器出來看發現SDO腳位波形不正確(波形截圖如附檔)。
使用SPI1:
SCK1 → RC3
SDI1 → RC4
SDO1 → RC0
SS1 → RC2


請問一下是不是有甚麼地方設定上有錯誤?感謝!

Attach file:



jpg  tek00002.jpg (159.25 KB)
79959_6065724e95b87.jpg 1024X768 px

發表於: 2021/4/1 15:12
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... ]

教育訓練中心

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