濮阳木板激光刻字加工:请教ARM高手 有关2131和2210通过SPI相连的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/08 14:15:23
我在用2210和2131通过SPI接口进行通信,2210做主机发送数据,2131用中断形式接收数据,但是2210发送的数据始终无法触发2131的中断,进而无法接受数据,哪位达人能给小第指点一下,两块板子间的管脚连线应该怎么连,急,在此跪谢拉:
2131板上程序:
#include "config.h"
#define SALVE (1 << 29)
#define LED 0xff << 16
volatile uint8 RcvData;
volatile uint8 RcvFlag;
void DelayNS(uint32 dly)
{
uint32 i;
for(; dly>0; dly--)
for(i=0; i<50000; i++);
}
void __irq SPI_IRQ(void)
{
uint32 tmp;
tmp = SPSR;
RcvData = SPDR;
RcvFlag = 0x01;
SPINT = 0x01;
VICVectAddr = 0x00;
}
void SPI_Init(void)
{
S0PCR = (0 << 3) | (1 << 4) |
(0 << 5) |
(0 << 6) |
(1 << 7);
}
int main (void)
{
uint8 rcv_data;
PINSEL0 = (PINSEL0 | 0x00005500);
PINSEL2 = PINSEL2 & (~0x08); IO1DIR = LED;
IO0DIR = SALVE;
IOCLR= SALVE;
IRQEnable(); SPI_Init();
VICIntSelect = 0x00000000;
VICVectCntl0 = (0x20 | 10);
VICVectAddr0 = (int32)SPI_IRQ;
VICIntEnable = (1 << 10);
while(1)
{

if(RcvFlag != 0)
{
rcv_data = RcvData;
IO1CLR = rcv_data <<16 ;
DelayNS(200);
IO1SET = rcv_data <<16 ;
DelayNS(200);
}

}

return 0;
}

2210板上程序:
#include "config.h"
#define HC595_CS (1 << 29)
void DelayNS(uint32 dly)
{
uint32 i;

for(; dly>0; dly--)
for(i=0; i<50000; i++);
}

void MSPI_Init(void)
{
PINSEL0 = (PINSEL0 & (~(0xFF << 8))) | (0x55 << 8) ;
SPCCR = 0x52;
SPCR = (0 << 3) | (1 << 4) | (1 << 5) | (0 << 6) | (0 << 7);
}

uint8 MSPI_SendData(uint8 data)
{

IOCLR = HC595_CS;
SPI_SPDR = data;
while( 0 == (SPI_SPSR & 0x80));
IOSET = HC595_CS;
return(SPI_SPDR);
}

uint8 const DISP_TAB[8] = {1,2,3,4,5,6,7,8,9};

uint8 rcv_data;
int main (void)
{
uint8 i;

PINSEL0 = 0x00005500;
PINSEL1 = 0x00000000;
IODIR = HC595_CS;

MSPI_Init();
while(1)
{

for(i=0; i<8; i++)
{
rcv_data = MSPI_SendData(DISP_TAB[i]);
DelayNS(80);
}

}

return 0;
}

uint8 rcv_data;
int main (void)
{
uint8 i;

PINSEL0 = 0x00005500;
PINSEL1 = 0x00000000;
IODIR = HC595_CS;

MSPI_Init();
while(1)
{

for(i=0; i<8; i++)
{
rcv_data = MSPI_SendData(DISP_TAB[i]);
DelayNS(80);
}

}

return 0;
}

你把2210和2131的位置调换一下试试看~!