Hello, I'm trying to use for my first time the kinetis software with processor expert and I want to set up the SPI to send digital value to a DAC. I started by including from the component library Init_SPI. I selected my MOSI pin, I disabled the MISO, because my MKL25Z must only send the data to a slave, DAC, (I don't know if it is correct), now, I don't know if I have to set up the SS (slave selected) pin or not? I don't know if I have to include the SPI_MasterLDD from the component library or not. Can you guide me or show me an example? thank you
Hi,
I don't know if I have to set up the SS (slave selected) pin or not?
You should check the Slave device signal specification. Sometimes is needed to toggle SS pin by GPIO instead of by SPI peripheral. CPOL, CPHA settings should be double-checked on your side too.
I don't know if I have to include the SPI_MasterLDD from the component library or not.
best regards
Vojtech Filip
Ok thanks. I have setted up the SPIMaster_LDD, so, the output pin the clock pin the clock period and so on, How can I create the function to send data? are there specific function? I don't know how can I find it
Hello,
If you open the Help of the SPIMaster_LDD component (open the context menu of the SPIMaster_LDD component in the Components windows and select the Help on Component command), you can find code examples on the Typical Usage page of the component's help. For example (SPIMaster_LDD without interrupts):
#define BLOCK_SIZE 4
uint8_t OutData[BLOCK_SIZE] = "0123";
uint8_t InpData[BLOCK_SIZE];
volatile LDD_SPIMASTER_TError ComError = 0U;
LDD_TError Error;
LDD_TDeviceData *MySPIPtr;
void main(void)
{
...
MySPIPtr = SM1_Init(NULL); /* Initialization of SM1 component */
SM1_SelectConfiguration(MySPIPtr, 1U, 1U); /* Select chip select 1 and attribute set 1 */
Error = SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception */
Error = SM1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE); /* Start transmission/reception */
while (!SM1_GetBlockReceivedStatus(MySPIPtr)) { /* Wait until data block is transmitted/received */
SM1_Main(MySPIPtr);
}
SM1_SelectConfiguration(MySPIPtr, 0U, 0U); /* Select chip select 0 and attribute set 0 */
Error = SM1_ReceiveBlock(MySPIPtr, InpData, BLOCK_SIZE); /* Request data block reception */
Error = SM1_SendBlock(MySPIPtr, OutData, BLOCK_SIZE); /* Start transmission/reception */
while (!SM1_GetBlockReceivedStatus(MySPIPtr)) { /* Wait until data block is transmitted/received */
SM1_Main(MySPIPtr);
}
}
Best Regards,
Marek Neuzil