cancel
Showing results for 
Search instead for 
Did you mean: 

binary and invert converion

Ranjeet Singh
Senior

i am sending data on serial is 3 when is display is this 3 but i can conver in bninary then become 00110011 instead 00000011.and when i invert it then i got 01100110 instead of 11111100 ,why so ?

33 REPLIES 33

IR Remote with STM32

Today in this tutorial I am going to interface IR Remote with STM32 microcontroller. IR Remote Controllers and receivers follow some standard protocols for sending and receiving data. Some of these protocols are NEC , JVC , SIRC etc. Here we will be discussing only the NEC protocol. I will also use LCD16x2 to display the key pressed on the remote. But first let’s see what NEC protocol is.

https://controllerstech.com/ir-remote-with-stm32/

thank you but thet are using TSOP,we are not using TSOP,we are using Simple IR Recevier 

thank you but they are just interface the IR module ,but we want to tranmit the signal

JTP1
Lead

Hello

If external logic inverter helps to get right data, probably setting Rx line inversion on does the same thing (or Tx line). It seems that data is totally interved when it goes thru IR transmitter and receiver.

If you are using STM32/HAL/Cube you should find this setting under advanced features of Uart/Usart:

JTP1_1-1690021354934.png

Maybe this way you finally get your data inverted :D

Br J.T

 

right

but may i know what operation they have used ?:D


@Ranjeet Singh wrote:

but may i know what operation they have used ?:D


It's a polarity reversal, so if the transmitter sends in normal mode, and the receiver receives with reversed polarity, the bits are reversed. It should look similar to what the bitwise function does (var2 = ~(val1);).

Note: The TTL signal (0V to 5V or 3.3V) is already inverted in the RS232 protocol, so it's good not to confuse things.

 

ttl-timing

Source: RS-232 vs. TTL Serial Communication

when i use (var2 = ~(val1);). this operation the data not match it becoome another data and that is the confusion why it become another data


@Ranjeet Singh wrote:

when i use (var2 = ~(val1);). this operation the data not match it becoome another data and that is the confusion why it become another data


Your problem is really a mystery, if maybe you could share your code for someone to test maybe someone can give some more assertive help.

Anyway, it might be interesting to watch these debug videos:

STM32CubeIDE Advanced Debug Features