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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
1,083件の閲覧回数
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 解決策
807件の閲覧回数
thoomanwang
Contributor V

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

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
807件の閲覧回数
thoomanwang
Contributor V

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

0 件の賞賛
返信
807件の閲覧回数
adriancano
NXP Employee
NXP Employee

Hi,

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

Best Regards,

Adrian

0 件の賞賛
返信
807件の閲覧回数
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 件の賞賛
返信
807件の閲覧回数
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 件の賞賛
返信
808件の閲覧回数
thoomanwang
Contributor V

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

0 件の賞賛
返信