We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Im using LPC1778 to simulate SSP1. The usermanual states that DR for SSP1 is at address 0x40030008. When I transmit data, I immediately receive data into the receive buffer(RNE flag in status register gets set) and also the value loaded into DR shown by Keil is not the value loaded by me into the DR.
//Send data U8 spi_send(U8 bChannelNo,U8 *pBufferPtr,U8 bLength) { U8 bDummy=0; U8 bReturn_val=0; bDummy++; bDummy=0; switch(bChannelNo) { case 0: ssp_12=LPC_SSP0; break; case 1: ssp_12=LPC_SSP1; break; case 2: ssp_12=LPC_SSP2; break; default: ssp_12=LPC_SSP0; break; } set_timeout2(10000); do { if(!(ssp_12->SR & (1<<4))) /*not busy*/ { if(ssp_12->SR & (1<<1)) /*tnf*/ { ssp_12->DR=*pBufferPtr; pBufferPtr++; bLength--; } } }while(((LPC_TIM2->TC) < (LPC_TIM2->MR1)) && ((LPC_TIM2->TC) != (LPC_TIM2->MR1)) && (bLength != 0)); if(bLength==0) { bReturn_val=1; } return bReturn_val; } //receive U8 spi_receive(U8 bChannelNo,U8 bLength,U8 *pRxDataBuff) { U8 bReturn_val=0; U8 bLoc=0; switch(bChannelNo) { case 0: ssp_12=LPC_SSP0; break; case 1: ssp_12=LPC_SSP1; break; case 2: ssp_12=LPC_SSP2; break; default: ssp_12=LPC_SSP0; break; } set_timeout2(10000); do { if(!(ssp_12->SR & (1<<4))) /*not busy*/ { if(ssp_12->SR & (1<<2)) /*rne*/ { pRxDataBuff[bLoc]=ssp_12->DR; bLength--; bLoc++; } } }while(((LPC_TIM2->TC) < (LPC_TIM2->MR1)) && ((LPC_TIM2->TC) != (LPC_TIM2->MR1)) && (bLength != 0)); if(bLength==0) { bReturn_val=1; } return bReturn_val; }
I used CMSIS driver examples for lpc1778 but still data is immediately received on sending and memory address doesnt contain the tx data. Why is Keil doing that?
Sorry.My bad.
Thanks for the answer. You gave me clarity as to which approach of my code will work and also cleared my doubts.
Cheers :)