PIC30F SPI编程的问题
各位:
我用PIC30F5013实现SPI通信,相关寄存器初始化后,在debug下,运行到SPI1BUF = data时就里立刻退出了,
但不知道是哪里的问题,
初始化的代码如下:
void Init_SPI()
{
// Following code snippet shows SPI register configuration for MASTER mode
IFS0bits.SPI1IF = 0; //Clear the Interrupt Flag
IEC0bits.SPI1IE = 0; //disable the Interrupt
//SPI1CON1 Register Settings
SPI1CONbits.DISSDO = 0; //SDO1 pin is controlled by the module.
SPI1CONbits.MODE16 = 1; //Communication is word-wide (16 bits).
SPI1CONbits.SMP = 0; //Input Data is sampled at the middle of data
SPI1CONbits.SPRE = 0; //Secondary prescale 8:1
SPI1CONbits.PPRE = 0; //Primary prescale 64:1 output time.
SPI1CONbits.CKE = 0; //Serial output data changes on transition from
//Idle clock state to active clock state
SPI1CONbits.CKP = 0; //Idle state for clock is a low level; active
//state is a high level
SPI1CONbits.MSTEN = 1; //Master Mode Enabled
SPI1STATbits.SPIROV = 0; //Clear the SPIROV status bit.
SPI1STATbits.SPIEN = 1; //Enable SPI Module
//Interrupt Controller Settings
IFS0bits.SPI1IF = 0; //Clear the Interrupt Flag
IEC0bits.SPI1IE = 1; //Enable the Interrupt
}
谢谢指点! |