[an error occurred while processing this directive]
|
// read byte at adr
unsigned char SPI_ReadByte(unsigned int adr)
{
unsigned char page, byte1;
page=SFRPAGE;
SFRPAGE=CONFIG_PAGE;
FRAM_nCS=0; // start transaction
SFRPAGE=SPI0_PAGE;
SPIF=0;
SPI0DAT=0x03; // send READ opcode
while(!SPIF);
SPIF=0;
SPI0DAT=(unsigned char)(adr >> 8); // send adr HI byte
while(!SPIF);
SPIF=0;
SPI0DAT=(unsigned char)(adr & 0x00FF); // send adr LO byte
while(!SPIF);
SPIF=0;
// read data
SPI0DAT=0xFF; // send dummy byte for SCK generation !!!
while(!SPIF);
byte1=SPI0DAT;
SPIF=0;
SFRPAGE=CONFIG_PAGE;
FRAM_nCS=1; // end transaction
SFRPAGE=page;
return(byte1);
}
E-mail: info@telesys.ru