Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/10/01 10:11
Read: times


 
#13982 - RE: SPI on ADuC824
May be you can use my code which I've wrote for ADuC812 to connect it with Atmel Flash RAM AT45D021 trough SPI.

void intSPI ( void ) interrupt 7 using 1 // vector address 0x3B
{
nSPIDAT = SPIDAT;
bGetSPI = 1;
}

void ResetSPI( void ) {
AT45_RESET = 0; // Start Reset AT45D021 chip
AT45_READY = 1; // For digital input purpose
AT45_CS = 0;
Delayms(10);
AT45_CS = 1;
AT45_RESET = 1; // End of reset of chip
bGetSPI = 0; // flag for intSPI that data are ready

// This for you ...
// CONFIGURE SPI...
ISPI=0; // set at the end of SPI transfer
WCOL=0; // collision error
SPE =1; // SPI enable now
SPIM=1; // MASTER MODE
CPHA=1; // CLOCK PHASE SELECT both are 1
CPOL=1; // CLOCK POLARITY / for mode 3
SPR1=1; // 1 + 1 so Fosc/64
SPR0=0; //
// ENABLE INTERRUPTS
IE2 = 1; // enable SPI interrupt
EA = 1; // enable inturrupts
}

// while send byte you read another
// and opposite if you read one byte
// you should send some one ( NOP )
byte SPI_IO (byte n) { while ( AT45_READY == 0 ); // wait here while chip is busy
SPE=1;
bGetSPI = 0; // flagĀ ...
SPIDAT = n; // send value 'n'
while( !bGetSPI ); //
SPE=0; //
// nSPIDAT !
return (byte)nSPIDAT;
}

Happy programming.

List of 6 messages in thread
TopicAuthorDate
SPI on ADuC824            01/01/70 00:00      
RE: SPI on ADuC824            01/01/70 00:00      
RE: SPI on ADuC824            01/01/70 00:00      
RE: SPI on ADuC824            01/01/70 00:00      
RE: SPI on ADuC824            01/01/70 00:00      
RE: SPI on ADuC824            01/01/70 00:00      

Back to Subject List