help in MC68HC11 microcontroller

Thread Starter

hamid_twaty

Joined Aug 10, 2011
1
Hello all;

I have written the code below to transfer the data from the Master to Slave by using MC68HC11 microcontroller ,but I can not transfer the data from Slave to Master... please help

-------------slave-------------
#include<stdio.h>
#include<iof1.h>
void main(void)
{

unsigned char data,rate,*padr,*paddr;
unsigned char dummy;
padr=(unsigned char*)0x00;
paddr=(unsigned char*)0x01;
*paddr=0xff;

for(;
{

DDRD |= 0x38;
PORTD = 0x00;
SPCR = 0x40;
SPCR |= rate;
SPDR=data;
while((SPSR & 0x80)==0){};
dummy=SPDR>>8;
PORTD |= 0x20;
PORTD &= ~0x20;
SPCR = 0x00;

printf("data from port A %02x\n\r",SPDR);
*padr=SPDR;
}

}


---------------master-------------------
#include<stdio.h>
#include<iof1.h>
void main(void)
{

unsigned char *adctl,*adr1,data,rate;
unsigned char dummy;
adctl=(unsigned char*)0x30;
adr1=(unsigned char*)0x31;
*adctl=0x20;
for(;
{
while (((*adctl)&0x80)==0x00);



DDRD |= 0x38;
PORTD = 0x00;
SPCR = 0x50;
SPCR |= rate;
SPDR=*adr1;
while((SPSR & 0x80)==0){};
dummy=SPDR>>8;
PORTD |= 0x20;
PORTD &= ~0x20;
SPCR = 0x00;

}

}




thank you
 
Top