📄 main.c
字号:
#include <cdefBF533.h>
void Init_PLL(int MSEL)
{
int new_PLL_CTL;
*pPLL_DIV = 0x0005;
asm("ssync;");
new_PLL_CTL = (MSEL & 0x3f) << 9;
// new_PLL_CTL |= 0x1; //set DF pass CLKIN/2 to PLL
// enable Wake-up from PLL event
*pSIC_IWR |= 0xffffffff;
if (new_PLL_CTL != *pPLL_CTL)
{
*pPLL_CTL = new_PLL_CTL;
asm("ssync;");
asm("idle;");
}
}//end Init_PLL
section("SDRAM") unsigned char rcv_data[40960];
section("SDRAM") unsigned char send_data[40960];
#define TESTNUM 100
main()
{
unsigned char temp;
Init_PLL(22);
int i = TESTNUM;
while(i--)
{
send_data[i] = i;
}
Drv_config_to_master();
Drv_config_master_write();
Drv_SPI_enable();
for (i=0; i<TESTNUM-1; i++)
{
*pSPI_TDBR = send_data[i];
while(*pSPI_STAT & TXS);
}
*pSPI_TDBR = send_data[i];
Drv_SPI_disable();
printf("send data success\n");
Drv_Config_master_read();
Drv_SPI_enable();
// for (i=0x60000000; i>0; i--)
// asm("nop;");
Drv_clean_revbuf();
for (i=0; i<TESTNUM; i++)
{
while(!(*pSPI_STAT & RXS));
rcv_data[i] = *pSPI_RDBR;
}
for (i=0; i<TESTNUM; i++)
if (rcv_data[i] != send_data[i])
{
printf("data error\n");
printf("%10d\n", i);
printf("%10x\n", rcv_data[i]);
printf("%10x\n", send_data[i]);
}
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -