#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
#include "Delay.h"
#define SPI_CLOCK 1
//-----------------------------------------------------------------------------------------------------------
void SPI_Initial(void)
{
#if SPI_CLOCK == 0
clr_SPR1;
clr_SPR0;
#elif SPI_CLOCK == 1
clr_SPR1;
set_SPR0;
#elif SPI_CLOCK == 2
set_SPR1;
clr_SPR0;
#elif SPI_CLOCK == 3
set_SPR1;
set_SPR0;
#endif
/* /SS General purpose I/O ( No Mode Fault ) */
set_DISMODF;
clr_SSOE;
/* SPI in Master mode */
set_MSTR;
/* MSB first */
clr_LSBFE;
clr_CPOL;
clr_CPHA;
/* Enable SPI function */
set_SPIEN;
}
//-----------------------------------------------------------------------------------------------------------
void SPI_W_D(char DATA)
{
SPDR = DATA;
while((SPSR&0x80)==0x00);
clr_SPIF;
}
//-----------------------------------------------------------------------------------------------------------
void main(void)
{
/* Note
MCU power on system clock is HIRC (22.1184MHz), so Fsys = 22.1184MHz
*/
Set_All_GPIO_Quasi_Mode;
SPI_Initial();
while(1){ SPI_W_D(0x55);}
}
//-----------------------------------------------------------------------------------------------------------
|