AnsweredAssumed Answered

I use  MC9S12XE256  ,but why" SPI1SR_SPTEF" is always "1",when complete transmiting,i place data into the transmit data register,but " SPI1SR_SPTEF" do't clean?

Question asked by li yong on Aug 27, 2014

my code:

void SPI1_Init(void)

  {

   //uint8_t temp;

   SPI1CR1=0x04;

   (void)SPI1SR;

   (void)SPI1DR;

   /*SPPR2~SPPR0=011=3,SPR2~SPR0=010=2 ,最终波特率为 Fbus /(3+1)*(2^(2+1)),假设总线频率为32M。那么算下来SCLK=1M */

   SPI1BR=0x32;

   

   SPI1CR2=0x40;  /*D7=0 D6=XFRW=1数据传输16位,=0是8位 D5=0 D4=MODFEN=0*/

   

    /*SPIE=0 禁止中断,SPE=1 使能SPI模块,SPTIE=0 发送中断禁止,MSTR=1主机工作模式,CPOL=1 SCLK空闲为高电平,CPHA=1 时钟第二个沿采集数据,SSOE=0 片选脚不用,LSBFE=0 MSB先传*/

   SPI1CR1=0x5e;

   

  }

 

 

uint8_t SPI1_Send_Data(uint16_t Send_Data)

{

  uint16_t i;

 

  while(!(SPI1SR_SPTEF));/*wait empty,then load new data*/

  SPI1DR= Send_Data;

 

 

      return 0;

}

Outcomes