how i should configure spi at45db161
tell me some basic idea how to read and write thank you
Plz go through datasheet of AT45DB161 dataflash. and usermanual of LPC 2378.You will get idea for interfacing.
Shaym T.
Are you going to transfer data in both directions? I don't know about the AT45DB161, but the LPC2378 has DMA or FIFO which means that it can run as slave at very high speeds without having troubles picking up incoming data.
A lot of processors only have a single shift register for incoming/outgoing transfers, so you may have a very short time to pick up the just received byte before it gets overwritten by the next bit on the way in from the master.
thank u i written this code for simple raed and write operation with spi but i m not getting
InitSPI();
IOCLR0 = SPI0_SEL; Write_SPI(0x84); // opcode Write on buffer 1 Write_SPI(0x00); Write_SPI(0x55); // data into buffer 1
// data = Read_SPI();
Write_SPI(0x83); //opcode buff to MM Write_SPI(0x00); // location of MM Write_SPI(0x00); // location of MM Delay(1000);
Write_SPI(0x54); // Read opcode for buffer 1 Write_SPI(0x00); // bufffer address
Delay(1000); data = Read_SPI(); TransmitChar0(data>>8); TransmitChar0(data);
} /***************************************** /* main end */ void InitSPI(void) { PCONP |= (1 << 8); PINSEL0 |= 0xC0000000; //P0.15 PINSEL1 |= 0x0000003C; //P0.16,P0.17,P0.18 PCONP |= (1 << 8); S0SPCR = 0x00; IODIR0 = SPI0_SEL; IOSET0 = SPI0_SEL; S0SPCR = 0x20; S0SPCCR = 0x96; // Check it first }
void Write_SPI(unsigned char spiTx) { S0SPDR = spiTx; while(!(S0SPSR & SPIF)); } unsigned char Read_SPI() { unsigned char spiRx; spiRx = S0SPDR; return (spiRx); } void SPI_ISR (void) __irq { S0SPINT = 0x01;
VICVectAddr = 0x00000000; }
The instructions for posting source code are very clear and easy to follow:
www.danlhenry.com/.../keil_code.png
If you can miss something so obvious as that, and not even notice the problem in the Preview or in the actual post - and do it twice - then it is very likely that you have missed important details in the NXP documentation.
Go back to the NXP documentation and study it thoroughly...
thank you sir,
actulally i m not getting sck clock from the processor, i checked that pin on CRO . in lpc user manual they given that in master mode clock counter value is even and equal to 8 or greater than this. i initialised tthat value also but then also i m not getting sck on that pin. whenever i get clock then i will go ahead. this is my code .. int main (void) { SYS_TargetResetInit(); PCONP |= (1 << 8); /* by default, it's enabled already, for safety reason */ PINSEL0 |= 0xC0000000; PINSEL1 |= 0x0000003C; S0SPCCR = 0x8; ** how much value i should enter i tried so many freqvency above 0x8 S0SPCR = 0x000; }
void SYS_TargetResetInit(void) { SCS |= 0x20; /* Enable main OSC */ while( !(SCS & 0x40) ); /* Wait until main OSC is usable */ CLKSRCSEL = 0x1; /* select main OSC, 12MHz, as the PLL clock source */ PCLKSEL0 = 0x55555555; /* PCLK is the same as CCLK */ PCLKSEL1 = 0x55555555; SYS_GPIOResetInit(); }
thank u
actulally i m not getting sck clock from the processor, i checked that pin on CRO . in lpc user manual they given that in master mode clock counter value is even and equal to 8 or greater than this. i initialised tthat value also but then also i m not getting sck on that pin. whenever i get clock then i will go ahead. this is my code .. < pre> int main (void) {
SYS_TargetResetInit();
PCONP |= (1 << 8);
/* by default, it's enabled already, for safety reason */ PINSEL0 |= 0xC0000000;
PINSEL1 |= 0x0000003C;
S0SPCCR = 0x8;
S0SPCR = 0x000;
}
void SYS_TargetResetInit(void) {
SCS |= 0x20;
/* Enable main OSC */
while( !(SCS & 0x40) );
/* Wait until main OSC is usable */
CLKSRCSEL = 0x1;
/* select main OSC, 12MHz, as the PLL clock source */
PCLKSEL0 = 0x55555555;
/* PCLK is the same as CCLK */
PCLKSEL1 = 0x55555555;
SYS_GPIOResetInit();
} .