Hi everyone,
I have a big problem with a serial display that need a Inverted TTL to comunicate (bit start=1, data inverted, bit stop=0),
so I Know that not exist any serial software library on Arduino DUE and in my project I can't use a external PNP to invert the signal..
Any idea for a software solution?
Can I create a wire jumper that "Digital.read" the Tx signal , invert it and create a digital output ? or simply a register option who "invert" the serial port signal?
You can make the serial port run in inverted mode. For a previous person I posted the following snippet as a way to do what they wanted:
#include "USARTClass.h"
Usart *_pUsart;
void setup() {
// put your setup code here, to run once:
_pUsart = USART0; //USART0 is Serial1, change this for other serial ports
_pUsart->US_MR = US_MR_USART_MODE_RS485 | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_EVEN |
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL;
}
void loop() {
// put your main code here, to run repeatedly:
}
You can do the same thing. You need to set inverted mode in your mode call and you probably don't want many of the other options that that user needed. But, you could do this:
All of these mode setting definitions are found in arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/include/component/component_usart.h
And, remember, all that code was setting the mode for Serial1. If you aren't using Serial1 then you will need to that _pUsart = line. Serial is NOT a USART but rather a UART and the mode definitions are probably different. You should still be able to do the same basic thing but you'll have to look up the mode bits.
Hello,
last question about this topic.., trying to understand better the INVDATA function I read the manual but I can't understand very well the meanig of this... :~
"• INVDATA: INverted Data 0: The data field transmitted on TXD line is the same as the one written in US_THR register or the content read in US_RHR is the same as RXD line. Normal mode of operation. 1: The data field transmitted on TXD line is inverted (voltage polarity only) compared to the value written on US_THR register or the content read in US_RHR is inverted compared to what is received on RXD line (or ISO7816 IO line). Inverted Mode of operation, useful for contactless card application. To be used with configuration bit MSBF.".......
In my application I need that even the bit start and stop are inverted but I think INVDATA works only on data field...
Any solutions? I'm wrong?
Thank you again
Only for a saving reason, a transistor means a new external PCB = a lot of money in large number..And a matter of elegance of design, if one thing can be simulated, why do it in real world ?
I can't belive that ARDUINO DUE can't send a full "inverted serial signal"
A quick (and untested) thought - perhaps the PIO devices have an invert register?
[ then I looked and it seems not... there is support for open-drain, probably what I
was half-remembering ]
Anyway this option might be fruitful still:
Can I create a wire jumper that "Digital.read" the Tx signal , invert it and create a digital output ? or simply a register option who "invert" the serial port signal?
Connect to a spare pin and use that to trigger an interrupt driving yet-another-pin... Not
great for high speed though. I don't think there's a way to patch-panel the pins in hardware
(might be useful for this sort of problem and for generating antiphase signal pairs).
The other way is to hack the software serial and do it like that. I also have never come across a processor with an inverted UART capability, so you are asking for something very unusual.
To be honest the "invert" option in Serial software is born because the world is full of "ttl inverted" devices ... So if you have a little experience... is not so unusual....
By the way thnks
the world is full of "ttl inverted" devices ... So if you have a little experience... is not so unusual....
Yes but I have been playing this game for over 40 years and I have never come across them.
I did design an RFID reader where it was required that the signals from a decoder was inverted serial but that's about it. I also play in the comms space where you would expect to come across them.
Guess I just lead a sheltered life.
The thing is that TTL logic floats high and that is a natural for a mark on a serial line, mark being the un-driven state of a line.