Questions regarding Atmega32 use of Multiprocessor (MPCM) and RS-485
Using ICCAVR C compiler with Olimex ATMega32 board.
I understand from the manual the following setup conditions for multiprocessor comm using the UART
Serial port in an RS-485 environment. It is convenient to use the acronym MPCM hereafter.
To set up the Master:
The 9 bit char frame format is set by setting the UCSZ bits to 111 (7). This is done via two separate registers, UCSRB bit 2 and UCSRC bits 1 & 2.
When transmitting the slave address, TXB8 must be set and set prior to writing to UDR.
I understand this to be the only requirements to set the MPCM mode?
To set up the Slave:
The MPCM bit set in UCSRA (bit 0). I think this allows the slave to only look for the 9 bit data?
Also, I think it is better to use the UART RX interrupt to examine the UDR data. Looking at a sample code on the AVR Freaks, it looks like the RX interrupt will occur regardless of the setting of MPCM?
In that case, the slave firmware would then examine the UDR contents and determine if the address is for that
Slave. Question: Does the slave need to also verify that RXB8 bit is set as well?
If it not the addressed slave, then nothing else happens at the slave. If the address is a match, then the slave
will disable the MPCM bit and this is what allows the slave to receive data , 8 bit data as is usually normal.
At this point, the Master must also change the UCSZ bit(s) to reflect the normal 8 bit data format before any data
can be sent to the slave?
In using the ICCAVR C compiler, it looks like I have to select the 9 bit set when using the application builder that I have come to appreciate.
The business of using the UCRSC URSEL bit, per the manual, seems a little bit confusing and I am not sure
If the ICCAVR compiler knows which register you want to use.
I am testing the MPCM mode(s) out just using a simple RS-232 between two ATMega32 devices. The firmware and UART should not care how the data arrives.
I did a search on the Freaks forum and did find an example code, but it leaves some of the above mentioned details
Out of the listing. It also seems targeted more to the receive/slave side, but did offer a great deal more understanding on my part.
As you may see, I am still fumbling with getting this going and would greatly appreciate any help, suggestions and example codes. Thanks in advance.
Also, thanks to theusch for his example code I mentioned above.