Content originally posted in LPCWare by LearnERR on Fri Oct 18 15:43:51 MST 2013
Hello!
I am very new to lpc11xx. Could someone help me with an example (if it is possible) how to make SSP read/write simultaneous function?
I am interested in manual Chip Select (CS), and I have used SSP_Send( 0, &MCU_Writebyte, 1 ); and SSP_Receive( 0, &MCU_Readbyte, 1 ); but would it give me a simultaneous read/write? I mean would I catch a reply of for the dummy frame for example send via SSP_Send (please see image attached for requirement). This is just a routine for write and read one byte, and I call this routine very often controlling CS as GPIO pin outside of it.
Also how to make a simple delay routine that would wait in the code for 20ms? Should I use sys tick, or timer32?
Is this one ok?
void delay32Ms(uint8_t timer_num, uint32_t delayInMs)
{
if (timer_num == 0)
{
/* setup timer #0 for delay */
LPC_TMR32B0->TCR = 0x02;/* reset timer */
LPC_TMR32B0->PR = 0x00;/* set prescaler to zero */
LPC_TMR32B0->MR0 = delayInMs * ((SystemCoreClock/(LPC_TMR32B0->PR+1)) / 1000);
LPC_TMR32B0->IR = 0xff;/* reset all interrrupts */
LPC_TMR32B0->MCR = 0x04;/* stop timer on match */
LPC_TMR32B0->TCR = 0x01;/* start timer */
/* wait until delay time has elapsed */
while (LPC_TMR32B0->TCR & 0x01);
}
else if (timer_num == 1)
{
/* setup timer #1 for delay */
LPC_TMR32B1->TCR = 0x02;/* reset timer */
LPC_TMR32B1->PR = 0x00;/* set prescaler to zero */
LPC_TMR32B1->MR0 = delayInMs * ((SystemCoreClock/(LPC_TMR32B0->PR+1)) / 1000);
LPC_TMR32B1->IR = 0xff;/* reset all interrrupts */
LPC_TMR32B1->MCR = 0x04;/* stop timer on match */
LPC_TMR32B1->TCR = 0x01;/* start timer */
/* wait until delay time has elapsed */
while (LPC_TMR32B1->TCR & 0x01);
}
return;
}
Thank you!!
Uli