2013-11-06 12:34 AM
Hello,
i'm trying to get a USART connection to a device with the parameters: USART 9600 Baud, 9 (real)Databits, 1 Start bit, 2 stop bits, parity odd. I configured my USART like this: USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_9b; USART_InitStructure.USART_StopBits = USART_StopBits_2; USART_InitStructure.USART_Parity = USART_Parity_Odd; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; The Problem is, that the receiver dont understand my commands. Somebody in a german forum told me, that the STM32 cant handle this mode, because the 9th bit is used for the parity an i have to do this with software USART. Ist this right? I cant believe that. In the RM0033 - 24.3.1 ''Figure 224. Word length programming'' it looks so :( How can i solve this problem in a smart way? Any Ideas? regards Florian #throwing-my-stapler2013-11-06 01:36 AM
Use an external UART or a small slave microcontroller.
JW2013-11-06 03:45 AM
I have to implement this in the STM32F2 Controller. An additional component is not a cheap way :)
2013-11-06 04:03 AM
> I have to implement this in the STM32F2 Controller.
Then you have to go for bit-banging. > An additional component is not a cheap way :) This heavily depends on your definition of cheap... JW2013-11-06 04:38 AM
Do you need Tx only, or Tx and Rx? Remember someone having an odd LCD display module using a 9-bit protocol discussed here some time ago.
If just Tx, could you use a SPI 16-bit mode to emulate the signalling? Slave, with TIM generating a baud rate clock? What are you communicating with that needs such a non-standard protocol?2013-11-06 04:58 AM
Now of course this is up to the OP, but IMO it's not any simpler than bit-banging in timer interrupt. Contrary maybe.
There are of course latency considerations, but, cm'on, 9600 Baud on a multitenmegahertz 32-bitter? Oh how many times did we this on the 8-bitters at a few megahertz back then... JW2013-11-06 05:17 AM
Just throwing it out there. We just seem to see a lot of posters who focus on the implementation problems, without adequately framing the question.
I know how and where to find the STM32 documentation, and some of it's capabilities, what I don't know is anything about the device being attached. So, I'm using XYZ display, and it's requirement is 9-bit Odd Parity at 10 Kbaud, here's a cite for the datasheet. Would be far more useful.2013-11-07 01:12 AM
Hello clive1,
i need Rx and Tx. At this Time i build a Timer with an 104µs interupt and shift the bits to a port. it works fine, but: i would like to implement a better (smarter) solution. Something with DMA access maybee. With my question i would like to learn more about the possibilities of an STM32 µC. I hoped to get an hint or idea of a real crack :) (Only reading the manual wouldn't be succesfully in this case ) regards Florian2013-11-07 04:14 AM
I think the SPI peripheral could be used for TX (Slave mode, with TIM driven baud clock), a TIM peripheral in Input Capture could time stamp edges for RX which could be decomposed, perhaps accumulated via DMA. Bit harder as the number of edges is variable depending on the symbol.
2013-11-07 05:17 AM
Hello clive1,
thanks for your idea. i will check the actual portconfig and discuss it. regards Florian