LPC2138 SPI kullanmak istiyorum fakat dogru cıkıs elde edemedim

Başlatan riggs, 10 Şubat 2011, 20:08:23

riggs

LPC2138 in SPI ını kullanmak istiyorum fakat dogru cıkıs elde edemedim.....

[IMG]http://img13.imageshack.us/img13/1535/adszazo.png[/img]

Uploaded with ImageShack.us

#include"LPC21XX.h"
void Initialize(void);



/************************* MAIN *************************/
int main()
{
Initialize();
IODIR0 = 0x00000100;      //Slave select
IOCLR0 = 0x00000100;

/* Write data out */
S0SPDR = 0xFF;

IOSET0 = 0x00000100; //Slave select
while(1)
;
}
/*************** System Initialization ***************/
void Initialize()
{
/* Configure Pin Connect Block */
PINSEL0=0x00005500;
/* Set pclk to same as cclk */
VPBDIV=0x00000001;
/* Set to highest speed for SPI at 10 MHz- > 1.25 MHz */
S0SPCCR=0x00000008;
/* Device selected as master */
S0SPCR=0x00000020;
}
/*********************************************************/

riggs

while ( !(S0SPSR & (0x80)) );      deyimi eksik olduğu için SPI okuması bitmeden kalıyordu. Cevap için tesekkür ederim.

MMC karttan resete komutu gonderimi bitmeden beklenmedik bir cevap alıyorum. 80 adet clock gonderdikten sonra reset komutunu gonderim işlemi bitmeden kart beklenmeyen bir cevap veriyor. sebebi ne olabilir....
int mmc_init()
{									  
DWORD i;
//BYTE MMCWRData[MMC_DATA_SIZE];
BYTE MMCRDData[MMC_DATA_SIZE];
BYTE MMCCmd[MMC_CMD_SIZE];
BYTE MMCStatus = 0;
/* Generate a data pattern for write block */
for(i=0;i<MMC_DATA_SIZE;i++)
{
//MMCWRData[i] = i;
}
MMCStatus = 0;
IOSET0 = SPI_SEL; /* set SPI SSEL */
/* initialise the MMC card into SPI mode by sending 80 clks on */
/* Use MMCRDData as a temporary buffer for SPI_Send() */
for(i=0; i<10; i++)
{
MMCRDData[i] = 0xFF;
}
SPI_Send( MMCRDData, 10 );
IOCLR0 = SPI_SEL; /* clear SPI SSEL */
/* send CMD0(RESET or GO_IDLE_STATE) command, all the arguments
are 0x00 for the reset command, precalculated checksum */
MMCCmd[0] = 0x40;
MMCCmd[1] = 0x00;
MMCCmd[2] = 0x00;
MMCCmd[3] = 0x00;
MMCCmd[4] = 0x00;
MMCCmd[5] = 0x95;
SPI_Send( MMCCmd, MMC_CMD_SIZE );
/* if = 1 then there was a timeout waiting for 0x01 from the MMC */
if( mmc_response(0x01) == 1 )
{
MMCStatus = IDLE_STATE_TIMEOUT;
IOSET0 = SPI_SEL; /* set SPI SSEL */
return MMCStatus;
};


[IMG]http://img20.imageshack.us/img20/7194/adsz2rt.png[/img]

Uploaded with ImageShack.us




riggs

Gayet normal bişeymiş, kart daha sonra normal cevap verdi