/*****SLAVE_CODE*****/
//* KUTHSAV*//
//*Including Header Files Required*//
#include <mega32.h>
#include <stdio.h>
#include <stdlib.h>
#include <delay.h>
#include <string.h>
//*Declaring LCD PORT as PORT A*//
#asm
.equ __LCD_PORT=0x1B; PORTA
#endasm
#include <lcd.h>
#define baud 0x33 /* Baudrate=9600 at 8Mhz IRC Oscillator*/
#define UCB 0xDC /*Enabling TXIE, RXIE TX and RX in 9bit*/
#define rxb 1
#define slave_address 0x01;
/*Declaring Global Variables*/
unsigned char si=0,qi=0,i=0,p=0,j=0,k=0,l=1,g=1,n=0,m=0;
unsigned char z;
unsigned char dl=2000;
char flag;
//char *cmd=NULL;
//char *msg=NULL;
char q[160];
char ch1[60];
char ch2[30];
char ch3[30];
char ch4[6];
char ch5[5];
char control,status,data;
void usart_init(void)
{
UCSRA=0x01;
UCSRB=UCB;
UCSRC=0x06;
UBRRH=0x00;
UBRRL=baud;
}
interrupt [USART_TXC] void usart_transmit_isr(void)
{
if(qi!=si)
{
UCSRB&=(~(0X01));
UDR=q[si++];
}
}
interrupt [USART_RXC] void rx_isr(void)
{
status=UCSRA;
control=(UCSRB&(1<<rxb));
data=UDR;
// lcd_putchar(data);
if(status&(0x01)==1)
{
UCSRA&=(~(0x01));
lcd_putchar('o');
}
else
{
lcd_putchar(data);
}
}
void main(void)
{
lcd_init(16);
//delay_ms(10);
#asm("sei")
usart_init();
while(1)
{
;
}
}
/*****END_SLAVE_CODE*****/
/*****MASTER_CODE*****/
//?MultiProcessorCommunication?//
//* KUTHSAV*//
//*Including Header Files Required*//
#include <mega32.h>
#include <stdio.h>
#include <stdlib.h>
#include <delay.h>
#include <string.h>
//*Declaring LCD PORT as PORT A*//
#asm
.equ __LCD_PORT=0x1B; PORTA
#endasm
#include <lcd.h>
#define baud 0x33; /* Baudrate=9600 at 8Mhz IRC Oscillator*/
#define UCB 0xDC; /*Enabling TXIE, RXIE TX and RX in 9bit*/
/*Declaring Global Variables*/
unsigned char si=0,qi=0,i=0,p=0,j=0,k=0,l=1,g=1,n=0,m=0;
unsigned char z;
unsigned char dl=2000;
char flag;
//char *cmd=NULL;
//char *msg=NULL;
char q[160];
char ch1[60];
char ch2[30];
char ch3[30];
char ch4[6];
char ch5[5];
char ch,ph;
void usart_init(void)
{
UCSRA|=0x00;
UCSRB|=UCB;
UCSRC=0x06;
UBRRH=0x00;
UBRRL=baud;
}
interrupt [USART_TXC] void usart_transmit_isr(void)
{
if(qi!=si)
{
UCSRB&=(~0x01);
UDR=q[si++];
}
}
void send_address(unsigned char slave)
{
UCSRB|=0x01;
UDR=slave;
delay_us(1000);
UCSRB&=(~0x01);
}
void send_data(char *s)
{
qi=0;
si=1;
while(*s)
{
q[qi++]=*s++;
}
UDR=q[0];
}
interrupt [USART_RXC] void rx_isr(void)
{
ch=UDR;
}
void main(void)
{
#asm("sei")
lcd_init(16);
usart_init();
send_address(0x01);
send_data("Kuthsav");
while(1)
{
;
}
}
/*****END_MASTER_CODE*****/
did you check it in 8 bit mode?
//* KUTHSAV*//
//*Including Header Files Required*//
#include <mega32.h>
#include <stdio.h>
#include <stdlib.h>
#include <delay.h>
#include <string.h>
//*Declaring LCD PORT as PORT A*//
#asm
.equ __LCD_PORT=0x1B; PORTA
#endasm
#include <lcd.h>
#define baud 0x33 /* Baudrate=9600 at 8Mhz IRC Oscillator*/
#define UCB 0xDC /*Enabling TXIE, RXIE TX and RX in 9bit*/
#define rxb 1
#define slave_address 0x01;
/*Declaring Global Variables*/
unsigned char si=0,qi=0,i=0,p=0,j=0,k=0,l=1,g=1,n=0,m=0;
unsigned char z;
unsigned char dl=2000;
unsigned char flag=0;
//char *cmd=NULL;
//char *msg=NULL;
char q[160];
char ch1[60];
char ch2[30];
char ch3[30];
char ch4[6];
char ch5[5];
char control,status,data;
void usart_init(void)
{
UCSRA|=0x01;
UCSRB|=UCB;
UCSRC|=0x06;
UBRRH=0x00;
UBRRL=baud;
}
interrupt [USART_TXC] void usart_transmit_isr(void)
{
if(qi!=si)
{
UCSRB&=(~(0X01));
UDR=q[si++];
}
}
interrupt [USART_RXC] void rx_isr(void)
{
if(flag==0)
{
status=UCSRA;
control=(UCSRB&(1<<rxb));
data=UDR;
if((UCSRA&0x01)==1)
{
if((control>>1)==1)
{
UCSRA&=(~(0x01));
UCSRB=0xD8;
// lcd_putchar('o');
flag=1;
return;
}
}
}
else if(flag==1)
{
data=UDR;
lcd_putchar('i');
lcd_putchar(data);
return;
}
}
void main(void)
{
lcd_init(16);
//delay_ms(10);
#asm("sei")
usart_init();
while(1)
{
;
}
}
Can you post the 2 hex files and proteus .dsn file. zip and post it.
I got this error. Please post the complete project files zipped.
----------------------Update---------------
I t shows kuthsav. Should the slaves read the data Kuthsav and display it on lcds?
lcd data was not correct ascii value. I think data is missing in communication.
I got this error. Please post the complete project files zipped.
----------------------Update---------------
I t shows kuthsav. Should the slaves read the data Kuthsav and display it on lcds?
Which Compiler are you using?
CodeVisionAVR.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?