mostly garbage output from serial UART of microcomputer STM32F091RC on target board - serial-port

Expected first printf line of software to serial output to Windows7 PC is:
main() ************************** SW START Project 2016-10-30 x1
Actual serial output (at TeraTerm or PuTTY);
▒▒▒▒()j**j*j**j*j**j*j**j*j**j*j ▒▒Ӕ▒Ҕ ▒▒▒▒▒▒▒ r01v-q0-30▒q
Serial worked great from mbed or VisualGDB to NUCLEO evaluation board.
ie.:
Serial pc(USBTX, USBRX);
Now, I'm running VisualGDB to the actual target board with a STM32F091RC.
ie.:
Serial pc(SERIAL_TX, SERIAL_RX);
At 9600, some chars are correct, most are garbage.
I've tried alternate target and cables, same problem. PC's Terminal program (TeraTerm or PuTTY) set at 8,n,1.
Looked in mbed library; default config is 8 data, no parity, 1 stop.
USB/serial converter cable is: FTDIChip TTL-232R-RPi (normally for Raspberry Pi).

It could be clock mismatch between eval board and target board. Assuming, you have correct grounding.
Another issue could be number of data bits in configs is off.

I guess it is not relevant anymore, but you have to pay attention to this points.
The Signal level is 3.3v and not 5v, not all USB Uart adapters work correctly with is
The polarity is the inverted to the standard, i.e. start bit is 1.5bit low like here

Ensure you have correct parity and bits. Most people (and Arduino) use 8N1 by default, but STM32 sample code uses 7O1 by default. See here: https://community.st.com/thread/40340-stm32cubefwf2v140projectsstm32f207zg-nucleoexamplesuartuartprintf-printing-garbage-data-over-the-terminal

Related

HC-05 Bluetooth module help, can not recieive data

I am writing some code for my arduino nano and I am using an HC-05 module for wireless transfer of data. I am sending my data as such. This is from the serial monitor, using a usb and regular print statements. I want to be able to recieve this data, and the store it in a csv (I know how to store incoming data). I need help recieveing my data.
22:17:46.765 -> =============================================================
22:17:47.770 -> Sleep timer:242
22:17:47.770 -> Light Sleep: 0 Deep Sleep: 0
22:17:47.805 -> Total Light Sleep: 0 Total Deep Sleep: 0
22:17:47.838 -> Total Sleep: 0
22:17:47.871 -> =============================================================
For some reason, when I connect my HC-05 to my windows desktop via bluetooth, and open a serial monitor in com ports 3 or 4, I get no read out.
My ports
I have it set up as so.
My wireless intialization
Then, I use
MySerial.print()
, to send data, yet I get no output, same thing occurs if I use
Serial.print()
.
I tried getting a new HC-05 module, Switched out all the hardware, tried different prints including Serial and MySerial. I though i could get an output.
Python code I tried to use python to extract the data, yet I get no output. I am not sure what to do here.
Not enough information, but I'll answer biased on the experience I've had with these modules.
Here are instructions for changing or verifying the baud rate on the module:
https://www.instructables.com/Change-the-Baud-Rate-of-HC-05-Bluetooth-Module-Usi/
For my module, I could just send AT commands by default without putting it into AT mode. Send 'AT' to the module and it should respond with "OK".
It helps a ton if you have an ftdi cable for troubleshooting. Connect the ftdi to the HC-05, verify the baud rate and that the HC-05 is responding, open a serial monitor for the bluetooth on the pc and one for the ftdi cable. Try sending data back and forth. Also, be 100% sure you're using the correct com port for your bluetooth by unpairing and repairing and see which com port shows up.
It actually is possible to use the HC-05 for programming the Arduino as well if you set the baud rate to 115200 and figure out a way to hit reset on the Arduino as soon as the bluetooth connects(status/state goes solid). I used an ATTiny for that, but you could just use a pin on the nano connected to reset and another pin to monitor the "state" pin which is connected to the led on the HC-05. That way you can have wireless data and wireless programming if you wanted that.

Arduino - Sparkfun USB host

I am building a device and need to use a USB Nordic ID rfid reader. I have a Spark-fun USB host card (V9947), and now need the firmware to allow be bi directional chat in a 'rs232' style serial... just as if it were a hardware or software serial port on the Arduino.
Nordic support have reassured me that their library and examples for the Arduino are normally used with readers with RS232 ports, however the same code will work with their smaller USB device if I can overcome the USB/serial barrier.
I have the library and examples for the USB host board, but cannot determine which example code resembles my requirement requirement, I have looked through the library and found no answer there either.
This could be down to personal stupidity/ignorance... however never been this stumped before. the internet does not seem to have an answer, documentation and support for this board are at best meager.
I hope someone here has managed to solve what should be a simple mission, and I can get on with this project.
Thanks Ian
As not knowing what you already have done, I'll make a walk through the complete setup. Please check(do) each point evenif you think its done already:
Soldering and hardware have no shorts
pin headers of the shield are soldered with no shorts
USB Jack of Arduino is isolated on the top to prevent shorts
With the SparkFun board, it seems like you MUST supply external power on Vin or the barrel jack. 5V from the USB cable will not work reliable.
You must also run a jumper from pin D7 to RESET.
For the board (SparkFun DEV-09947) set up – these are mandatory pre-requirements.Now the software
The code/drivers you need to use for this board are on this GitHub page.
There is a diagnostic test which is extremely useful for checking wether your board is working correctly. Do as follows:
Upload this sketch to your Arduino, then open the Serial Monitor to see the diagnostic info.
To see the output set your Serial Monitor terminal speed to 115200
Plug in your hardware into the USB of the shield
Reset the Arduino to start the diagnostic
Step 1 – you’ll see it recognize the board and start a transfer test
Step 2 – you’ll see it attempt to test the GPIO pins – you’ll get “GPIO test failed” message. Type something in the box at the top of the Serial Monitor, then hit “Send” button and the diagnostic test will continue.
Step 3 – you should see it cycle through a bunch of resets, then it will attempt to detect an USB device – as we have a device plugged into the USB port on the shield you should then see some summary info with a final message of “All tests passed”
So NOW we know the hardware is working and basic software is running.
Next step driver installation/test program for the Nordic
Get the library from here
Import NurMicroApi_arduino.zip to IDE. From menu: Sketch->Include library->Add .ZIP library...
Open example. From menu: File->Examples->NurMicroApi->NurExample
Change baudrates and sw serial pins to match your arduino HW In this example NUR module is connected to arduino via software serial pin 10 (RX) and pin 11 (TX) with baudrate 38400. HW serial is used as print output.
You may have to change this to the USB card connections (see diag-SW)
As an easier option you can use the HID parser to check if your NUR is recognized If that works take a working exmple like:
Working HID example and try to read a tag then start coding with the NUR example from above if values are not correct interpreted
If you want to use the "pure" at-Terminal (RS-232) style you have to get rid of the usb shields functions (lib) and write your own Arduino firmware based (=overcome the USB/serial barrier) on the nordic-api (well documented) Hope this gets you started

USB serial device seems to drop characters at baud rate above 9600 bps

The background of this is the following: I own an Atlys FPGA board, and I am busy implementing a UART on it, because the possibilities for other diagnostics are rather limited.
I want to use a portable (on which I also run the FPGA software) as terminal for the board. The portable is from 2004, AMD x64, 1 GB of RAM, running Linux 3.2.0.4 kernel on Debian. The board contains an XR21V1410 serial to USB bridge, which is driven by the Vizzini driver (2013).
The result is that this works fine for 9600 bps. However, going to 19200 it seems that data is dropped. This happens independently of the speed at which I supply data. E.g. I can throttle the system to only send 1 char/s, or 80 chars/s, data still get dropped. I am trying to find out where the problem could occur.
The data I send is a stream of characters A..Z, followed by 0d 0a.
Diagnostics using two ways of reading /dev/ttyUSB0 give different results. With minicom, it seems that the data is garbled so that it receives control codes. I suppose that this is because minicom emulates the VT102.
Reading the device raw (cat /dev/ttyUSB0), it seems that it sometimes receives correct characters in a stream, but not always.
Does anybody have experience with usbserial and the maximum attainable data rates on Linux? That is the first cause that I would like to try to exclude.

Upload a HEX firmware to Arduino board

is it possible to upload a firmware to an ATMEGA328P aka Arduino Uno using a serial terminal like Putty or Coolterm?
I know that the Arduino is ready to receive a new firmware after a reset over USB, does the IDE (and avrdude) makes something different other than echoing the binary hex file over serial port?
Thanks
Theoretically, yes. It would be awkward, and you'd need to be able to send and receive arbitrary bytes within a strict time limit, before the bootloader gives up waiting, but you could do it.
The most common bootloaders for the atmega328 use Atmel's STK500 protocol, originally designed for their own AVR development boards but widely used elsewhere (such as on the Arduino). Documentation for this protocol can be found here.
Note that Optiboot, used on modern Arduinos, implements only a subset of this protocol.

UART - wrong symbols on PC

I'm writing a simple program to transmit data from the MCU to the PC.
I'm using FTDI cable to achieve that.
Data that I'm sending is string digits from 0 to 9 (0x30 to 0x39 as ascii codes).
Both the MCU and the PC terminal are configured to 9600 kbps, 8 bits, no parity, no flow control, one stop bit.
When the data transferred from the MCU to the PC - symbols are wrong.
When TX and RX lines of the MCU are both connected to each other - I can see, that all symbols that were sent, were received by the MCU.
When TX and RX lines of the FTDI cable (connected to the PC) are connected to each other - all symbols that were sent from the PC terminal were received by the PC.
I cannot understand what can be wrong in sending data from the MCU to the PC.
Please, help!
The symptoms you describe suggest a timing mismatch between the PC and the MCU. UART serial comms can tolerate a baud rate mismatch of <5% at either end. In practice because teh PC is certainly accurate, you might get away with up to 10% in the embedded target - but that is extreme. Either the baud rate divisor for your part is incorrectly programmed, or your system clock is inaccurate or simply not the frequency you believe it to be. RC oscillators on some MCUs used to reduce costs can be off-nominal as bad as +/-10%.
You should verify the clock and the baud rate directly with an oscilloscope, or laboriously verify every clock setting from the PLL to the UART baud-rate generator.
The solution is more simple than I thought.
For my previous applications I used the ATC-810 cable (USB-to-UART, FT232BL chip).
At the past it worked, but now for some reason it doesn't works. New drivers from FTDI, may be...
When I took the TTL-232R-3V3 cable - all data that I'm sending from the MCU I'm receiving on the PC!
Thanks a lot for trying to help!!

Resources