about SPI of MKL05Z32,Why receive data is "\0" ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

about SPI of MKL05Z32,Why receive data is "\0" ?

跳至解决方案
1,091 次查看
thoomanwang
Contributor V

I use MKL05Z32 SPI interface with another device communications, MKL05 as Master, why the received data is always "\ 0"?

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
815 次查看
thoomanwang
Contributor V

The problem has been resolved, please see this post https://community.freescale.com/thread/333858

在原帖中查看解决方案

0 项奖励
回复
5 回复数
815 次查看
thoomanwang
Contributor V

Use MKL05 SPI interface communication, choose pin cs signal output began to output data after how long?

0 项奖励
回复
815 次查看
adriancano
NXP Employee
NXP Employee

Hi,

Can you please share the configuration you are using for the SPI module?

Best Regards,

Adrian

0 项奖励
回复
815 次查看
thoomanwang
Contributor V

void SPI_InitMater( void )

{

  // enable clock gate for spi module

   SIM_SCGC4 |= SIM_SCGC4_SPI0_MASK;

  

   // enable PORT

   SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK|SIM_SCGC5_PORTB_MASK;

 

   // disable SPI

   SPI0_C1 &= ~SPI_C1_SPE_MASK;

 

   // configure I/O to SPI function

   /*

  PORTA_PCR5 &= ~PORT_PCR_MUX_MASK;

  PORTA_PCR5 |= PORT_PCR_MUX(3)|PORT_PCR_DSE_MASK;  //Use PTA5 as SPI0_SS_b

  */

    PORTA_PCR6 &= ~PORT_PCR_MUX_MASK;

  PORTA_PCR6 |= PORT_PCR_MUX(3)|PORT_PCR_DSE_MASK;  //Use PTA6 as SPI0_MISO

    PORTA_PCR7 &= ~PORT_PCR_MUX_MASK;

  PORTA_PCR7 |= PORT_PCR_MUX(3)|PORT_PCR_DSE_MASK;  //Use PTA7 as SPI0_MOSI

    PORTB_PCR0 &= ~PORT_PCR_MUX_MASK;

  PORTB_PCR0 = PORT_PCR_MUX(3)|PORT_PCR_DSE_MASK;    //Use PTB0 as SPI0_SCK

  SPI0_C1 |= SPI_C1_MSTR_MASK;

  //SPI0_BR = 0x02;

  //SPI0_BR = (SPI_BR_SPPR(0x06) | SPI_BR_SPR(0x00));//速率1.713MHz

  //SPI0_BR = (SPI_BR_SPPR(0x02) | SPI_BR_SPR(0x02));

  SPI0_BR = (SPI_BR_SPPR(0x02) | SPI_BR_SPR(0x03));//436.907KHz

  SPI0_C1 |= SPI_C1_SSOE_MASK; 

  SPI0_C2 |= SPI_C2_MODFEN_MASK;

  SPI0_C2 |= SPI_C2_SPC0_MASK;

  SPI0_C2 &= ~SPI_C2_SPC0_MASK;

  SPI0_C1 |= SPI_C1_CPHA_MASK;

  SPI0_C1 &= (~SPI_C1_CPHA_MASK);

  SPI0_C1 |= SPI_C1_CPOL_MASK;

  SPI0_C1 &= (~SPI_C1_CPOL_MASK);

  SPI0_C1 |= SPI_C1_LSBFE_MASK;

  SPI0_C1 &= (~SPI_C1_LSBFE_MASK);

  SPI0_C1 |= SPI_C1_SPE_MASK;

}

用的例程中的配置,slave的极性和相位都是0

0 项奖励
回复
815 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Thooman wang,

     Could you tell me which your slave is?

     Can you make sure your slave is not out put "\0"?

   Waiting for your reply!

Jingjing

0 项奖励
回复
816 次查看
thoomanwang
Contributor V

The problem has been resolved, please see this post https://community.freescale.com/thread/333858

0 项奖励
回复