Hi to all,
I am using twr-k60f120m and codewarrior 10.2.Now i want interface SPI with DMA i.e DSPI,for first i would like verify DSPI clock for this what can do,if any one knows please help me.
Thanks and Regards,
padmaja
Hi,
Can you please explain more about the issue?
I would be happy to help you.
Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
Hi Adrian,
Thanks for your reply,I am using twr-k60f120m and codewarrior 10.2.Now i want interface SPI with DMA i.e DSPI, and i have external 24-bit ADC(sigma delta ADC),so now i want to interface 24-bit ADC to DSPI mode for this what can i do and i am very new to this,and first of all i want to check DSPI clock. please reply as soon as possible and i am waiting for your helpful suggestions.
Thanks and Regards,
padmaja
Hi,
You can initialize the peripheral and then check the state of the pins, here is a common initialization:
void SPI0_mstrInit()
{
SIM_SCGC6 |= SIM_SCGC6_SPI0_MASK; //SPI0 Clock Gate enabled
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTC_MASK; //Port A Clock enabled
PORTA_PCR17 = PORT_PCR_MUX(0x02); //SPI0_SIN //with the TWR-K60N512 rev d B19
PORTA_PCR16 = PORT_PCR_MUX(0x02); //SPI0_SOUT //with the TWR-K60N512 rev d B20
PORTA_PCR15 = PORT_PCR_MUX(0x02); //SPI0_SCK //with the TWR-K60N512 rev d B15
PORTA_PCR14 = PORT_PCR_MUX(0x02); //SPI0_PCS0 //with the TWR-K60N512 rev d A16
SPI0_MCR = SPI_MCR_MSTR_MASK | //DSPI is in Master mode.
SPI_MCR_ROOE_MASK | //Incoming data is shifted into the shift register.
SPI_MCR_PCSIS(0x00) | //The inactive state of PCSx is high.
SPI_MCR_CLR_TXF_MASK | //Clear the TX FIFO counter.
SPI_MCR_CLR_RXF_MASK | //Clear the RX FIFO counter.
SPI_MCR_HALT_MASK; //Stop transfers
//SPI0_MCR |= SPI_MCR_DIS_TXF_MASK | //Tx FIFO is disabled.
// SPI_MCR_DIS_RXF_MASK; //Rx FIFO is disabled. ;
SPI0_SR |= SPI_SR_TCF_MASK | //Clear transfer complete flag
SPI_SR_EOQF_MASK | //Clear End of Queue Flag
SPI_SR_TFUF_MASK | //CLear Transmit FIFO Underflow Flag
SPI_SR_TFFF_MASK ; //Transmit FIFO Fill Flag
SPI0_CTAR0 |= SPI_CTAR_FMSZ(0x0F) | SPI_CTAR_PBR(0x3); //Frame Size = 15 + 1
//SPI0_RSER |= SPI_RSER_RFDF_RE_MASK | SPI_RSER_RFDF_DIRS_MASK | SPI_RSER_TFFF_DIRS_MASK; /* Set DMA Interrupt Request Select and Enable register */
SPI0_MCR &= ~SPI_MCR_HALT_MASK; //Start transfers.
}
Hope this information can help you
Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi good morning Adrian,
Thanks for your reply,and have one more doubt about SPI clock,without peripheral initialization the SPI clock checking is possible or not if you knows please explain it,and if it is possible how to verify the clock let me know. and you have any example code with DSPI to External ADC or SPI to External ADC interfacing please provide and give me reply as early as possible.
Thanks and Regards,
padmaja
Hi Pallenna,
Please check K60 120MHz product reference manual chapter 53.4.3 about DSPI baud rate and clock generation.
The DSPI module clock source is bus clock.
About SPI communication with external SPI device example, I would recommend customer to check Kinetis 100MHz DSPI example, which K60 communication with external SPI Flash.
The code could be downloaded from here (KINETIS512_V2_SC).
Wish it helps.
Have a great day,
best regards,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Pallenna
I would recommend you to upgrade ur code warrior from 10.2 to either 10.6 or switch to KDS as many bugs are fixed in the newer version and u might not be getting much support for older version. For assistance u can use Processor Expert for configuration and later u can use the generated code for your learning. You can verify SPI clock by externally connecting the Oscilloscope, and also check the register's value in debug mode.
Regards
Amit
Hi Amit Kumar,
Thanks for your reply,we have checked all those possibilities what you have mentioned,but did not find any SCLK and CLK on the controller pins.we used the code what " adriancano " has mentioned.If have any more ideas you can suggest me please.
Best Regards,
padmaja