kmdineshece
Member level 1

I'm working with ATmega88PA, ATMEL Studio6.2.............
I have written a code for serial data transmission between one controller and PC but i want to communicate with multiple controllers, how to assign a ID for different controllers,
controller 1: ID A
controller 2: ID B
controller 3: ID C
If i send a data with ID: A, micro controller '1 'only receive those data......
I have written a code for only one controller!....
I have written a code for serial data transmission between one controller and PC but i want to communicate with multiple controllers, how to assign a ID for different controllers,
controller 1: ID A
controller 2: ID B
controller 3: ID C
If i send a data with ID: A, micro controller '1 'only receive those data......
I have written a code for only one controller!....
Code C++ - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #include <avr/io.h> #include <inttypes.h> #define FOSC 20000000 // Clock Speed #define BAUD 19200 #define MYUBRR FOSC/16/BAUD-1 void main( void ) { USART_Init(MYUBRR); while(1) { USART_puts("Dinesh"); } } void USART_Init( unsigned int ubrr) { /*Set baud rate */ UBRR0H = (unsigned char)(ubrr>>8); UBRR0L = (unsigned char)(ubrr); //Enable receiver and transmitter */ UCSR0B = (1<<TXEN0); ////=UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); /* Set frame format: 8data, 1stop bit */ UCSR0C = (1<<UMSEL00)|(1<<USBS0)|(1<<UCSZ01)|(1<<UCSZ00); } void USART_Transmit( unsigned char data ) { /* Wait for empty transmit buffer */ ////=while ((UCSRA & (1 << RXC)) == 0); while(!(UCSR0A & (1 << UDRE0))); /* Put data into buffer, sends the data */ UDR0 = data; } void USART_puts(unsigned char *s) { while(*s) { USART_Transmit(*s); s++; } }
Last edited by a moderator: