Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with SPI CLOCK in ARM lpc2368

Status
Not open for further replies.

chsp129

Junior Member level 3
Junior Member level 3
Joined
Mar 29, 2010
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
hyd
Activity points
1,479
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..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top