嗨,我开始用PIC18F26K40工作,我试着在从属模式下运行SPI1接口。我已经使用外围引脚选择(PPS)寄存器来分配SPI1控制线到波尔塔,如下所示。芯片看到SS断言,SCK1时钟和SDI1的数据从主机,但没有活动。在SDO1上没有出现中断。使用调试器,我在SSP1BUF中看不到数据的移动。同一个芯片SPI2被配置为主控器,它是有功能的。还有一个功能UART,它响应于接收中断。我有一个功能类似的PSP18F67 K22配置的SPI从属设备(唯一的区别是丢失的PPS寄存器),我想知道我在这里丢失了什么。下面是我对PIC18F26K40的SPI从机的寄存器设置。有人看到什么问题吗?//启用数字输入ANSELLA=0x00;和/或集成外围输入SSP1DATPPS= 0x02;//RA2作为SDI1 SSP1CKPPS= 0x04;//RA4为SCK1 SSP1SSPPS= 0x05;//RA5为SS1//集成外围输出RA3PPS= 0x10;//RA3为SDO1//启用SPI1端口线LATABI
tiTS。TSISA5=1;/SS1输入TrISABIIT.TISISA4=1;/SCK1输入TrISABIIT.TISISA3=0;/SDO1输出TrISABIIT.TISISA2=1;//SDI1输入SSP1STAT=0x40;//SET CKE位SSP1CON1= 0x04;//SPI从属模式,SS1控制使能TCNC0=0XE7;/ /允许中断和优先级/ /SPI1中断设置NG IPR3BITS.SSP1IP=0;/低优先级中断PIR3BITS.SSP1IF=0;/ /清除中断标志PY3BITS.SSP1IE=1;//启用中断/启用SPI1接口SSP1CON1BITS SSPEN=1;//中断配置ICONTITION IPEN=1;/ /启用中断优先级ICONTITY。GIHH=1;// EnablE高优先级中断ItCONTITE。GIEL=1;/ /启用低优先级中断谢谢!
以上来自于百度翻译
以下为原文
Hi,
I started working with PIC18F26K40 and I'm trying to run the SPI1 interface in Slave mode.
I have used the Peripheral Pin Select (PPS) registers to assign the SPI1 control lines to PORTA as shown below.
The chip sees SS asserted, SCK1 clock and data on SDI1 from the Master but there is no activity on SDO1 and no interrupt appears. Using the debugger I see no movement of the data in the SSP1BUF.
With the same chip SPI2 is configured as Master and it is functional. There is also a functional UART, which is responding to receive interrupt.
I have a functional SPI Slave with PIC18F67K22 configured a similar way (the only difference is the missing PPS registers) and I'm wondering what I'm missing here.
Below are my register settings for SPI Slave with PIC18F26K40. Does anybody see any issue?
// Enable Digital Inputs
ANSELA = 0x00;
// Integrated Peripheral Inputs
SSP1DATPPS = 0x02; // RA2 as SDI1
SSP1CLKPPS = 0x04; // RA4 as SCK1
SSP1SSPPS = 0x05; // RA5 as SS1
// Integrated Peripheral Output
RA3PPS = 0x10; // RA3 as SDO1
// Enable SPI1 Port Lines
LATAbits.LATA3 = 0; // SDO1 Low
TRISAbits.TRISA5 = 1; // SS1 Input
TRISAbits.TRISA4 = 1; // SCK1 Input
TRISAbits.TRISA3 = 0; // SDO1 Output
TRISAbits.TRISA2 = 1; // SDI1 Input
SSP1STAT = 0x40; // Set CKE bit
SSP1CON1 = 0x04; // SPI Slave Mode, SS1 Control Enabled
INTCON = 0xE7; // Enable Interrupts and Priorities
// SPI1 Interrupt Setting
IPR3bits.SSP1IP = 0; // Low Priority Interrupt
PIR3bits.SSP1IF = 0; // Clear the Interrupt Flag
PIE3bits.SSP1IE = 1; // Enable the Interrupt
// Enable SPI1 Interface
SSP1CON1bits.SSPEN = 1;
// Interrupt Configuration
INTCONbits.IPEN = 1; // Enable Interrupt Priority
INTCONbits.GIEH = 1; // Enable High Priority Interrupts
INTCONbits.GIEL = 1; // Enable Low Priority Interrupts
Thanks!
Attached Image(s)
0