SPI issue with K70 using PE and mqx lite

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI issue with K70 using PE and mqx lite

Jump to solution
1,161 Views
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 Kudos
Reply
1 Solution
700 Views
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

View solution in original post

0 Kudos
Reply
6 Replies
700 Views
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 Kudos
Reply
700 Views
leepenn
Contributor III

Here is the component settings from PE.

0 Kudos
Reply
701 Views
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 Kudos
Reply
699 Views
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 Kudos
Reply
700 Views
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 Kudos
Reply
700 Views
Angelillo
Contributor III

Ok Thank you very much Petr!

0 Kudos
Reply