如题,在proteus中仿真,没有问题,但是烧进片子,就开始一直发送0xff.
代码如下:
void SPI_Init(void)
{
VPBDIV = 0x10;
S0PCCR = 0x60;
S0PCR = 0x20;
}
void SPI_Send(uint8 data)
{
uint8 read;
IO0CLR |= 1<<12;
S0PDR = data;
while(0==(S0PSR&0x80));
read = S0PDR;
IOSET |= 1<<12;
}
uint8 DISP_TAB[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,
0x88,0x83,0xC6,0xA1,0x86,0x8E};
void Delay(uint8 t)
{
uint32 i;
for (;t>0;t--)
for(i=0;i<50000;i++);
}
int main(void)
{
PINSEL0=0x00005500;
PINSEL1=0x00000000;
IO0DIR|=1<<12;
IO0DIR|=(1<<4)|(1<<6)|(1<<5);
SPI_Init();
while(1)
{
for (i=0;i<16;i++)
{
SPI_Send(DISP_TAB[i]);
Delay(25);
}
}
return(0);
}
求高手指点啊,调了两天了,还没找到问题所在 |