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!....
You can use serial receive interrupt in each microcontroller and you can append the device ID to the beginning of the data you send so that the first byte will always be the ID. If a AVR received this data then it has to check if received 1st byte is the ID of that device. If yes, then it should do further processing of the received data else discard it.
You can use serial receive interrupt in each microcontroller and you can append the device ID to the beginning of the data you send so that the first byte will always be the ID. If a AVR received this data then it has to check if received 1st byte is the ID of that device. If yes, then it should do further processing of the received data else discard it.
I have not seen such examples but that is a method which you can try. Have you used serial receive interrupt ? If yes, then it is not a difficult task. You read the data into a buffer till \r or \n is received. Then you set a flag like received in the ISR. Then you check if this flag is true in the while(1) loop and if it is true then you check if 1st byte matches with the ID of that device. If yes then you do what you want based on the data received. I don't use AVR much and also I don't use Atmel Studio + GCC for writing the code. I use other compiler(s).
This is the code I wrote. Say, one AVR sends some string with 'A' as the first character of the string then this code for another AVR with ID A will receive it and takes required action on the data.