Kel C51 + simulace SPi u AT89C51ED2 ?

Tomáš Tomáš tom.tore@seznam.cz
Úterý Únor 14 03:17:49 CET 2006


Hraju si s simulatorem v C51 v 7.5 respektive 8.01 a zkousel jsme simulovat SPPI interface u AT89C51ED2, predpokladal jsem, ze na zaklade prikazu 
SPDAT=0x44;  
se provede zapis 0x44 do registu SPDAT a  data se nasledne odvysilaji na SPI interface, jinak receno po provedeni prikazu bude mit SPDAT hodnotu 0x44 a nasledne pujde na pinech P1.6 a P1.7 sledovat jak se data vysilaji, v simulatoru se nestalo ani jedno, je chyba ve me v pozdni nocni hodine, kodu nebo v simulatoru ?

Dekuji



main ()
{

SPCON |= 0x10;                /* Master mode */
SPCON |= 0x82;                /* Fclk Periph/128 */
SPCON |= 0x20;                /* P1.1 is available as standard I/O pin */
SPCON &= ~0x08;            /* CPOL=0; transmit mode example */
SPCON |= 0x04;                /* CPHA=1; transmit mode example */
IEN1 |= 0x04;                     /* enable spi interrupt */
SPCON |= 0x40;                /* run spi */
EA=1;                                  /* enable interrupts */

while(1)			   			/* endless  */
   {
   P1_1=~P1_1;                                 /* P1.1 is available as standard I/O pin */ 
   SPDAT=0x44;                                 /* send an data */
   while(!transmit_completed);/* wait end of transmition */
   transmit_completed = 0;    /* clear software transfert flag */

   SPDAT=0x00;                /* data is send to generate SCK signal */
   while(!transmit_completed);/* wait end of transmition */
   transmit_completed = 0;    /* clear software transfert flag */
   data_save = serial_data;   /* save receive data */  
   }

}


void it_SPI(void) interrupt 9 /* interrupt address is 0x004B */
{
	switch	( SPSTA )         /* read and clear spi status register */
	{
	case 0x80:
                                         serial_data=SPDAT;              /* read receive data */
                                          transmit_completed=1;        /* set software flag */
 		break;
	}
}





Další informace o konferenci Hw-list