Цитата(zltigo @ Sep 2 2009, 18:37)

Вам ответить в стиле Вашего вопроса, или попрбуете нормально рассказать что не получается?
Вот это и не получается. В слейве выдает 8 фреймов и все, в мастере и передает, и принимает, даже если кабель на друго проц выдернуть. Принимает исключительно 0xffff, причем только если в jtag-отладчике нажимать F5, если ходить пошагово - приема нет.
/* master.c */
#include "LPC230x.h" // Keil: Register definition file for LPC2378
#define MASTER 1
void LPCInit(void);
void SSP_Init(int master);
static int razs=0;
static int razr=0;
int mas[256];
int main()
{ int cmd=0, rcmd=0, par;
LPCInit();
#if MASTER
SSP_Init(1);
#else
SSP_Init(0);
#endif
while(1)
{
#if MASTER
if(SSP0SR & 0x02) //1= TNF Transmit FIFO Not Full.
{ SSP0DR = cmd;
cmd++;
razs ++;
}
if(SSP0SR & 0x04) //1= RNE Receive FIFO Not Empty
{ rcmd = SSP0DR;
mas[razr&0xff] = rcmd;
razr++;
}
#else
if(SSP0SR & 0x04) //1= RNE Receive FIFO Not Empty
{ rcmd = SSP0DR;
mas[razr&0xff] = rcmd;
razr++;
}
// if(rcmd != 0)
{
if(SSP0SR & 0x02) //1= TNF Transmit FIFO Not Full.
{ cmd = razr; //(rcmd&0xff) | ((razr<<8)& 0xff00);
SSP0DR = cmd;
razs++;
}
}
#endif
}
}
void SSP_Init(int master)
{
PCONP |= (1<<21); // power on SSP0 module (default = ON)
/* Вариант 0 /
PINSEL0 = 0x80000000; // configure P0.15 as SCK0
PINSEL1 = 0x0000002a; // configure P0.16 as SSEL0, 0.17 as MISO0, 0.18 as MOSI0
*/
/* Вариант 1 */
PINSEL2 = 0;
PINSEL3 = 0x3cf00; //11 1100 1111 0000 0000
/* */
//P1.20 SCK0, P1.21 - SSEL0, P1.23 - MISO0, P1.24 - MOSI0
SSP0CR0 = 0xf; // 16 бит
/*
SSP0CR0
15:8 SCR Serial Clock Rate. The number of prescaler-output clocks per bit on the bus, minus one. Given that CPSDVR is the prescale
divider, and the APB clock PCLK clocks the prescaler, the bit frequency is PCLK / (CPSDVSR x [SCR+1]).
*/
if(master)
{
SSP0CPSR = 2; // CPSDVSR Master
SSP0CR1 = 0x2; // Enabled, Master mode
} else {
SSP0CPSR = 12; // CPSDVSR Slave
SSP0CR1 = 0x6; // Enabled, Slave mode
}
}
void LPCInit(void)
{
T1TCR=1;
return;
}