Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help in MC68HC11 microcontroller

Status
Not open for further replies.

hamid_twaty

New Member
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top