Arduino Forum

Using Arduino => Programming Questions => Topic started by: ALAA72 on Nov 10, 2019, 07:05 am

Title: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 10, 2019, 07:05 am
Hi there!

I was working with a code to transfer some data. first I used ARDUINO and the function ShitOut() to shift the data to my Data pin. then I switched to STM32F407 Discovery board and I realized there is a function called HAL_USART_Transmit(). are these two functions identical? what are their main differences?
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 10, 2019, 07:26 am
Serial.write() (https://www.arduino.cc/reference/en/language/functions/communication/serial/write/)


You might be interested in using this easy to use, fast, and reliable serial data transfer library (https://github.com/PowerBroker2/SerialTransfer).
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 10, 2019, 07:37 am
Dear Power_Broker

what is this github file all about?
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 10, 2019, 07:41 am
what is this github file all about?
It's not a file, it's an Arduino library - you can even download it in the Arduino IDE "Libraries Manager".

Basically, one Arduino sends data to the library, the library "packetizes" the data and sends it via USART to another Arduino running the same version of the library. The receiving Arduino then uses the library to "depacketize" the data and allow the main Arduino code to access the data received.

The readme explains the library and it's example in as much depth as needed (if you disagree, let me know and I can edit it).
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 10, 2019, 07:59 am
Dear Power_Broker

yes, but what does it do with comparing STM32F407 function, HAL_USART_Transmit()?
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 10, 2019, 08:28 am
yes, but what does it do with comparing STM32F407 function, HAL_USART_Transmit()?
Literally the same thing, just better  :)

Check the example code in the readme
Title: Re: is there any SHIFTOUT()?
Post by: lastchancename on Nov 10, 2019, 08:53 am
Quote
I used ARDUINO and the function ShitOut() to shift the data
I believe the earliest references to ShitOut() were by IBM in the 1960s
The called it GIGO, an abbreviation of Garbage In Garbage Out
Title: Re: is there any SHIFTOUT()?
Post by: westfw on Nov 10, 2019, 09:45 am
Normally "shiftout" is a synchronous output that outputs both data and a clock signal, usually as fast as possible on any two pins, while UART functions output on a single pin ("asynchronously") on specific pins associated with the hardware, at speeds controlled by previous configuration.
Title: Re: is there any SHIFTOUT()?
Post by: Hinson685 on Nov 10, 2019, 10:02 am
This function starts at either the most significant or least significant bit in a byte value, and shifts out each byte in order onto a data pin. After each bit is written to the data pin, a separate clock pin is pulsed to indicate that the new bit is available DGCustomerFirst (https://www.dgcustomerfirst.net/)
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 10, 2019, 11:48 am
Dear westfw
but we can use USART which is synchronous with a clock. that's why it is called USART and not UART.

also

Dear Hinson685
your definition of ShiftOut() function is right. but I'm curious if both ShiftOut() and HAL_USART_Transmit() function can be identical?
Title: Re: is there any SHIFTOUT()?
Post by: MorganS on Nov 10, 2019, 12:07 pm
I think you answered your own question. If you program them to be identical then they are identical. One of them simply uses more hardware resources and less software.
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 10, 2019, 01:09 pm
Dear MorganS

I know that I should make them identical but I don't know HOW?????
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 10, 2019, 09:02 pm
I know that I should make them identical but I don't know HOW?????
What was wrong with using Serial.write() (https://www.arduino.cc/reference/en/language/functions/communication/serial/write/)?

What are you trying to do in your project? Are you trying to use USART?
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 11, 2019, 05:34 am
Quote
What are you trying to do in your project? Are you trying to use USART?
Dear Power_Broker

I had a project driving a printer module using ARDUINO. in that project I used ShiftOut() function to shift the data out.
then I switched to STM32F407 Discovery board. I used HAL_USART_Transmit() function to shift the data but now when I run the code, it does work as expected. it seems like HAL_USART_Transmit() doesn't shift the data out!
that's why I ask how can I make them identical???
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 11, 2019, 05:50 am
I'm going to ask this once more and ONLY once more: Are you trying to use USART?

If so, what is wrong with using Serial.write()?

If not, what EXACTLY is the interface with the printer? Is it RS-232? Is it USB? Is it SPI?...
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 11, 2019, 05:59 am
Quote
Are you trying to use USART?
Dear Power_Broker

yes I do want to use USART, but not in ARDUINO IDE! that's why I can't use Serial.Write()!

the IDE that I'm using now is KEIL, and it has its own functions, such as HAL_USART_Transmit().
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 11, 2019, 06:10 am
yes I do want to use USART, but not in ARDUINO IDE! that's why I can't use Serial.Write()!
Why are you so agitated that I don't know something you didn't tell me in the first place?!?


That doesn't even matter - if you're using the core arduino libraries, you can use Serial.write() in ANY IDE
Title: Re: is there any SHIFTOUT()?
Post by: ALAA72 on Nov 11, 2019, 06:24 am
Quote
That doesn't even matter - if you're using the core arduino libraries, you can use Serial.write() in ANY IDE
Dear Power_Broker

I'm not agitated :smiley-lol:
but before I continue I want to appreciate your help and support. thank you

about the thing you said, I don't really follow... you mean that I can use functions of arduino for stm32f407??? I've seen some tutorials which show how to run stm32f407 in arduino IDE but they require some modification in arduino IDE to work. plus, when you say that I can use a arduino function on any IDE, makes me confused! I sounds to me that you're implying that for example I can uce C functions in MATLAB IDE...
can you help more?
Title: Re: is there any SHIFTOUT()?
Post by: Power_Broker on Nov 11, 2019, 06:30 am
Sorry, it's all good - effective communication over text can be difficult.

Yes, you can use the Arduino IDE to program your board. Take a look at this (http://www.emcu.eu/2017/03/13/how-to-use-stm32-and-arduino-ide/).

Arduino is NOT a language - it's C++ with some wrapper logic. Therefore, you can use Arduino's (C++) libraries with other C++ compilers as long as the compiler works for your board's architecture.