Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with SPI CLOCK in ARM lpc2368

Hi to all

I am using LPC2368 for communicating an SPI based ADC.
I write all the code and dump into the board but I am not getting the clock from the clk pin ..

here is my code Just observe this ..

void SPI_init(void)
{
PINSEL0|=0xC0000000; /*Select spi clock pin*/
PINSEL1|=0x0000003C; /*Select spi slave select,miso,mosi pins*/
IODIR0 |=0x00010000;
// PINMODE1|=0x00000003;
S0SPCR=0x00000824; /*Select clk phase low, clk polarity as low(clk active high)*/
S0SPCCR=0x0C; /*Clk is divided with 8 so spi clk is 1.5Mhz*/
}
void SPI_write(unsigned char address,unsigned long int data,unsigned char length)
{
unsigned char read=0;
unsigned long int data2=data;

IOCLR0|=0x00010000;
address=(address|0x80);
S0SPDR=address; /*Write data inti SPI data register*/
while(!((S0SPSR)&&(0x80))); /*Poll the SPIF flag for data completion*/
read=S0SPDR; /*Read the data register for clear the SPIF flag*/
spi_delay();

if(length==12)
{
length=16;
}

do
{
length=length-8;
data2=(data>>length)&(0xFF);
S0SPDR=data2; /*Write data inti SPI data register*/
while(!((S0SPSR)&&(0x80))); /*Poll the SPIF flag for data completion*/
read=S0SPDR; /*Read the data register for clear the SPIF flag*/
spi_delay();
}while(length!=0);

}

void spi_delay(void)
{
unsigned int dd;
for(dd=0;dd<65000;dd++);
}

Any body please tell me Why clock is not generated..
Sign In or Register to comment.