打印

PIC30F SPI编程的问题

[复制链接]
1523|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xinyancode|  楼主 | 2011-11-19 12:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
}




谢谢指点!
沙发
yewuyi| | 2011-11-20 21:02 | 只看该作者
查看门狗是否溢出了?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

85

主题

147

帖子

0

粉丝