2014-10-16 04:02 PM
Hi guys,
Sorry for my bad English. I would set up with 9-bit UART. So I want the UART interrupt only when I get a character with 9 bits. If I get the 8-bit character, I do not want to be interrupted. Is it possible? Thanks.2014-10-16 05:11 PM
I'm not sure how exactly it's going to switch between 8 and 9-bit modes, perhaps you're thinking of ''Multiprocessor Mode'', in which case I suggest you read the manual descriptions.
STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\USART\MultiProcessor\readme.txt2014-10-17 05:16 AM
Thanks for your reply.
So, from what I saw and I tested, I only can set up the UART to wake up mode setting the UART address. But, I only want be interrupted when I receive a character 9-bit. My application works in cryptographic mode in a network with other devices and I have to receive 16 bytes in 9-bit only, deciphers this and if my address, I switch the UART to receive and 8-bit and communicate in 8-bit without the other devices (in 9-bit mode) receiving such information in this communication. Understand? Any suggestion?Thanks2014-10-17 05:21 AM
How does one recognize if a 0x55 character is using an 8 or 9-bit representation?
2014-10-17 05:45 AM
I suspect you're going to have to set the USART to 9-bit mode and process all in-coming characters. The interrupt loading is going to be minimal, and you have to read the data register anyway otherwise you're going to get overrun/overflow issues.
The most rational method to determine between one class of 8-bit values and another class of 8-bit values would be the presence or absence of a stop bit in the received data. The receiver has no mechanism to change framing before the character is received, and will jam up if you fail to service it.2014-10-17 05:46 AM
Independent the UART mode (9-bit or 8-bit) the character must be same. 0x55 in 9-bit and 0x55 in 8-bit are the same. The only difference is a interrupt. If I'm in 9-bit, I only interrupted when I receive the ninth bit. Imagine the network where exists 1 master and 4 slaves (all are in 9-bit mode). The master send a message (16 bytes) in the network (message is the slave address) in 9-bit. The slave validate the message with owner address, if is true, the slave switch the uart to 8-bit and communicate with master in 8-bit without the other slaves be interrupted (the other slaves are in 9-bit).
2014-10-17 06:04 AM
There is no way for an UART to distinguish 8-bit char from 9-bit chars. This is the same as if you wish distinguish char sent at 9600 and char sent at 38400.
Anyway, there is *maybe* (not guaranteed to work, etc ....) a trick you an use to perform your flow separation. Use the parity bit: slaves only answer when bit is set, and slave respond to the master using parity cleared. I did not even check if this possible with STM32s ...2014-10-17 06:28 AM
I work with Microchip PIC Microcontrollers and this feature also exist. See image below..
2014-10-17 06:54 AM
> I'm not sure how exactly it's going to switch between 8 and 9-bit modes
This is a misunderstanding based on poor terminology. The USART will always be in 9-bit mode, and ''8-bit data'' mean 9-bit data with MSB cleared. The 'F1 USART for some weird reason does not directly implement the 9-bit multiprocessor UART with a choice of ''manual'' or automatic address recognition, as we know it from the RD2 subfamily of 8051 and many of the modern standalone UART chips; it implements a strange crossover, where only a 4-bit address match is able to ''wake'' the USART from ''mute''. It does not implement MARK and SPACE parity either (this is how the 9-bit mutiprocessor communication is often implemented with the 16450-compatible UARTs, e.g. in PC), thus, as Clive said above, for your requirement, there is no other option than to ''manually'' process all received data. JW2014-10-17 07:11 AM
Sorry I must insist, there is no way for an UART to distinguish between 8-bit data and 9-bit data.
The Microchip EUSART does not work like you think. For ADDEN to work, the EUSART *must* always be in 9-bit mode. There is a convention (made in Microchip) that says address have 9th bit set and data have 9th bit clear. The address detection ignores 9-bit characters that have 9th bit clear. When the slave answer, the EUSART stay in 9-bit mode and send 8-bit character plus a cleared 9th bit. It could not work otherwise. If the EUSART were reprogrammed in 8-bit mode, the 9th bit on the wire will be the stop bit, which is 1, and the waveform on the wire will be received as an address by others slaves. The address mark detection of stm32 is similar. I did not test, but apparently it check the MSB. If you're lucky, program your uart in 9-bit mode, and the uart will only wake up to receive the address byte (only 4 LSB as address, limiting communication to 16 nodes), when the address match ''own address'', the reception continues, otherwise the uart stay idle. Read the manual. Jan: I am (probably too much) optimistic. The manual says that address matching is on 4 LSB and address mark on MSB. Maybe this will work as Rodrigo expect when the uart is in 9-bit mode: 4LSB as address, 4 don't care, and the address mark. Never tested though.