SPI issue with K70 using PE and mqx lite

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

SPI issue with K70 using PE and mqx lite

跳至解决方案
1,230 次查看
leepenn
Contributor III


I have a project in which I have initialized an spi port, My code using the SendBlock only has the CS and clock work for two bytes. When data size is set higher it leaves the CS and CLOCK low. See code below,

Task

  void PowerChip_task(uint32_t task_init_data)

  {

    int counter = 0;

    PowerChip_SPI_Init(PowerChip_SPI_DeviceData);

  PowerChip_InitSPI();

  while(1) {

      counter++;

       

    /* Write your code here ... */

      PowerChip_ReadSPI();

    }

  }

 

void PowerChip_InitSPI(void)

  {

         LDD_TError SPI_Error=0;

         int counter = 0;

 

       POWER_CHIP_SPI_DATA8_STRUCT DummyWrite={0xF};

   DummyWrite.OperationType=SPI_Write_Byte;

   DummyWrite.RegisterAddrLSB=SPI_DummyAddress>>1;

   DummyWrite.RegisterAddrMSB=SPI_DummyAddress>>8;

      //Initialize DIO reset of Power Chip

   PowerChip_Reset_Init(PowerChip_Reset_DeviceData);

  //Toggle reset of Power Chip

   PowerChip_Reset_ClrVal(PowerChip_Reset_DeviceData);

   _time_delay_ticks(50);

   PowerChip_Reset_SetVal(PowerChip_Reset_DeviceData);

   _time_delay_ticks(50);

         while (counter < 3)

        {

        SPI_Error=PowerChip_SPI_SendBlock(PowerChip_SPI_DeviceData,&DummyWrite,sizeof(DummyWrite));

                     if(SPI_Error>0)

               {

                                break;

               }

        ++counter;

        }

}


0 项奖励
回复
1 解答
769 次查看
Petr_H
NXP Employee
NXP Employee

Hi,

From your code, there seems to be missing some parts - there is no wait for end of the transfer.

Please see the help for the component (e.g. using pop-up menu command Help on Component") , the Typical usage page. It contains example of basic usage with and without using interrupts.

Your code in PowerChip_InitSPI passes a reference to local variable which might be a problem when the function ends but the sending would continue.

We have tested transfer of four bytes using your settings and it worked properly. We recommend to also check the bus if there is no other influence disturbing the communication.

best regards

Petr Hradsky

Processor Expert Support Team

在原帖中查看解决方案

0 项奖励
回复
6 回复数
769 次查看
Petr_H
NXP Employee
NXP Employee

Hi,

Could you please post a simple project with component and its settings ? It's not clear how the component and the CPU is configured.

best regards

Petr Hradsky

Processor Expert Support Team

0 项奖励
回复
769 次查看
leepenn
Contributor III

Here is the component settings from PE.

0 项奖励
回复
770 次查看
Petr_H
NXP Employee
NXP Employee

Hi,

From your code, there seems to be missing some parts - there is no wait for end of the transfer.

Please see the help for the component (e.g. using pop-up menu command Help on Component") , the Typical usage page. It contains example of basic usage with and without using interrupts.

Your code in PowerChip_InitSPI passes a reference to local variable which might be a problem when the function ends but the sending would continue.

We have tested transfer of four bytes using your settings and it worked properly. We recommend to also check the bus if there is no other influence disturbing the communication.

best regards

Petr Hradsky

Processor Expert Support Team

0 项奖励
回复
768 次查看
Angelillo
Contributor III

Hi Lee,

Have you got MQX Lite on K70?? I have seen that MQX Lite is compatible with KL series only...

Thank you,

Angel G.

0 项奖励
回复
769 次查看
Petr_H
NXP Employee
NXP Employee

The MQX lite is not supported on K70. It's currently available only for Kinetis L.

On K family, there is only standard MQX, which offers PEx support when you customize the BSP project.

best regards

Petr Hradsky

Processor Expert Support Team

0 项奖励
回复
769 次查看
Angelillo
Contributor III

Ok Thank you very much Petr!

0 项奖励
回复