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;
}
}
已解决! 转到解答。
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
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
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