[SOLVED] Serial only shows garbage data (custom board)

jamshaid
Thu Apr 19, 2018 6:59 pm
hello i am having a problem with stm32 duino board it programs ok but when i see the serial monitor it only shows garbage data

can anyone please help me
i am using Arduino IDE

my code is as under
int led = PC13;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(led, HIGH);
Serial.println("HIGH");
delay(1000);
digitalWrite(led, LOW);
Serial.println("LOW");
delay(1000);
}


edogaldo
Thu Apr 19, 2018 7:19 pm
Did you check the baud rate in the serial monitor is correct?

fpiSTM
Thu Apr 19, 2018 7:22 pm
It should be fine to give us more infos.

Which Core? Which board?
Which kind of garbage? I assume you set the terminal at 9600 ? :mrgreen:


RogerClark
Fri Apr 20, 2018 1:35 am
Depends which core you are using and also what Upload method you select

Serial can be USB serial or the hardware Serial

But I assume if you think you are getting data, you have configured things so that Serial is actually the hardware serial port ??


jamshaid
Fri Apr 20, 2018 2:12 pm
I am using FTDI to upload the code in arduino IDE using serial as upload method the code justs uploads fine atleast i can see the led blink code working ok
Even a simple code as
Serial.print(“Hello world”);
Is showing just garbage i am using ftdi to moitor serial connected at A9 and A10 pins respectively i uploaded the code from same port
My board has STM32f103c8t6

jamshaid
Fri Apr 20, 2018 2:43 pm
this is how I am trying to connect the board to ftdi
my baud rate at terminal is same as my code i did double check it :)

this what i get when i upload the code
http://stm32flash.googlecode.com/

Using Parser : Raw BINARY
Interface serial_w32: 115200 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory

Wrote address 0x08000100 (3.32%)
Wrote address 0x08000200 (6.65%)
Wrote address 0x08000300 (9.97%)
Wrote address 0x08000400 (13.30%)
Wrote address 0x08000500 (16.62%)
Wrote address 0x08000600 (19.95%)
Wrote address 0x08000700 (23.27%)
Wrote address 0x08000800 (26.60%)
Wrote address 0x08000900 (29.92%)
Wrote address 0x08000a00 (33.25%)
Wrote address 0x08000b00 (36.57%)
Wrote address 0x08000c00 (39.90%)
Wrote address 0x08000d00 (43.22%)
Wrote address 0x08000e00 (46.55%)
Wrote address 0x08000f00 (49.87%)
Wrote address 0x08001000 (53.19%)
Wrote address 0x08001100 (56.52%)
Wrote address 0x08001200 (59.84%)
Wrote address 0x08001300 (63.17%)
Wrote address 0x08001400 (66.49%)
Wrote address 0x08001500 (69.82%)
Wrote address 0x08001600 (73.14%)
Wrote address 0x08001700 (76.47%)
Wrote address 0x08001800 (79.79%)
Wrote address 0x08001900 (83.12%)
Wrote address 0x08001a00 (86.44%)
Wrote address 0x08001b00 (89.77%)
Wrote address 0x08001c00 (93.09%)
Wrote address 0x08001d00 (96.42%)
Wrote address 0x08001e00 (99.74%)
Wrote address 0x08001e14 (100.00%) Done.

Starting execution at address 0x08000000... done.


jamshaid
Fri Apr 20, 2018 2:44 pm
thats the garbage i am getting at serial monitor

stevestrong
Fri Apr 20, 2018 2:54 pm
I think for serial upload you have to first switch BOOT0 jumper to 1, then, after upload, switch it back to GND and press reset to run the software.

edogaldo
Fri Apr 20, 2018 2:55 pm
Looks like a clock problem..
When you ran the blink sktech, did it blink at the correct rate (1s ON + 1s OFF)?

jamshaid
Fri Apr 20, 2018 2:57 pm
i uploaded the LED_blinky code it is working ok i did switch back the jumper and reset the contrller but i am still getting garbage on serial

jamshaid
Fri Apr 20, 2018 3:00 pm
[edogaldo – Fri Apr 20, 2018 2:55 pm] –
Looks like a clock problem..
When you ran the blink sktech, did it blink at the correct rate (1s ON + 1s OFF)?

yes it runs fine at same rate i did get an arduino with it to test they both blink at same rate


RogerClark
Fri Apr 20, 2018 9:14 pm
Did you try other baud rates ?

E.g. when you send 1 character how many are received ?

Actually.. send 10 chars and see how many you get, less or more

Also what about parity, start bits stop bits etc, did you try changing those on the FTDI adapter side ?


madias
Fri Apr 20, 2018 10:23 pm
…really odd possibility:
Does the FTDI works “standalone” or with other devices?
This garbage output seems like the “brick firmware update” for counterfeit FTDI devices. (just google for it).
On such devices the output is permanent (please step trough the baudrates within the monitor) even without device (blue pill) connected and something like “you are using a counterfeit ….”

electrobling
Fri Apr 20, 2018 11:03 pm
Also it wouldn’t hurt to power the Blue Pill from the FTDI 3.3V supply instead of its own USB connector. Maybe you are getting some strange ground loop in the USB connections.

jamshaid
Sat Apr 21, 2018 4:10 am
[RogerClark – Fri Apr 20, 2018 9:14 pm] –
Did you try other baud rates ?

E.g. when you send 1 character how many are received ?

Actually.. send 10 chars and see how many you get, less or more

Also what about parity, start bits stop bits etc, did you try changing those on the FTDI adapter side ?

Tried that all changed baud rates changed parity changed stop bits used other serial monitors tried sending single character but i only get garbage :?


jamshaid
Sat Apr 21, 2018 4:12 am
[madias – Fri Apr 20, 2018 10:23 pm] –
…really odd possibility:
Does the FTDI works “standalone” or with other devices?
This garbage output seems like the “brick firmware update” for counterfeit FTDI devices. (just google for it).
On such devices the output is permanent (please step trough the baudrates within the monitor) even without device (blue pill) connected and something like “you are using a counterfeit ….”

Well the ftdi is working perfect with my arduino mega i will give a try to your suggestion


jamshaid
Sat Apr 21, 2018 4:15 am
[electrobling – Fri Apr 20, 2018 11:03 pm] –
Also it wouldn’t hurt to power the Blue Pill from the FTDI 3.3V supply instead of its own USB connector. Maybe you are getting some strange ground loop in the USB connections.

Well i happened to break the connector of blue pill in frustration and i am powering it through the ftdi power pins :lol:


jamshaid
Sat Apr 21, 2018 4:17 am
[RogerClark – Fri Apr 20, 2018 9:14 pm] –

Actually.. send 10 chars and see how many you get, less or more

My packet size does remain the same :(


RogerClark
Sat Apr 21, 2018 5:18 am
Not a baud rate issue if the number of chars you receive is the same as the number you send.

Possibly parity or start or stop bit issues

Possibly even voltage level issues


jamshaid
Sat Apr 21, 2018 6:16 am
[RogerClark – Sat Apr 21, 2018 5:18 am] –
Not a baud rate issue if the number of chars you receive is the same as the number you send.

Possibly parity or start or stop bit issues

Possibly even voltage level issues

I did try with 5v and 3.3v also did changed parity and stop bits as well but i am getting nothing.
I am guessinh there is some thing wrong with my stm board :roll:


stevestrong
Sat Apr 21, 2018 6:54 am
Why don’t you try the USB serial? You only need a USB cable to a micro-USB slot.

electrobling
Sat Apr 21, 2018 11:28 am
Is it not true that the serial pins PA9 and PA10 are addressed by default as Serial1, not Serial?

electrobling
Sat Apr 21, 2018 11:32 am
[jamshaid – Sat Apr 21, 2018 6:16 am] – I did try with 5v

You applied 5V to VCC? :shock:


jamshaid
Sat Apr 21, 2018 3:27 pm
[electrobling – Sat Apr 21, 2018 11:32 am] –

[jamshaid – Sat Apr 21, 2018 6:16 am] – I did try with 5v

You applied 5V to VCC? :shock:

I applied 5v to 5v pin on the board not the 3.3v pins


jamshaid
Sat Apr 21, 2018 3:55 pm
[stevestrong – Sat Apr 21, 2018 6:54 am] –
Why don’t you try the USB serial? You only need a USB cable to a micro-USB slot.

I broke the connector in frustration ��


electrobling
Sun Apr 22, 2018 12:56 am
The USB pins are duplicated right next to the serial pins you’re using. Double check to see that your connections are not offset by one pin. Also you haven’t acknowledged the difference between Serial and Serial1.

jamshaid
Sun Apr 22, 2018 5:39 pm
[electrobling – Sun Apr 22, 2018 12:56 am] –
The USB pins are duplicated right next to the serial pins you’re using. Double check to see that your connections are not offset by one pin. Also you haven’t acknowledged the difference between Serial and Serial1.

i will check the connections
In arduino default is serial but i do see Serial1 as default serial but if i print to serial1 it tends to stop working on that pin and shifts to serial 2 but the data outputs remains same


jamshaid
Sun Apr 22, 2018 6:06 pm
Ok so i started tracing the connections
So the oscilator at pins3 &4 has a resistor of 10k in series with it at one pin
The second oscilator at pin 5&6 has a value of 12.00000 and has a resistor in series at one pin ok 220. Ohms. is it normal?
I have never seen a resistor in series with an oscilator pin and the diagram shows that oscilator 2 should be of 8 Mhz

edogaldo
Mon Apr 23, 2018 11:40 am
12MHz oscillator?! This explains all!!
Is this a custom board?

RogerClark
Mon Apr 23, 2018 11:55 am
So the information about the blink rate was incorrect

The Blink sketch would flash on and off, faster than 1 second period

Also USB won’t work.

I recall someone else with a 12MHz board. So you could search to see what they did

Basically you need a custom Variant and change the PLL multiplier to x 6 rather than x 9


madias
Mon Apr 23, 2018 12:28 pm
Ok, this was a hard nut!
What Roger means:
–>
https://github.com/rogerclarkmelbourne/ … _setup.cpp
Line #54: change
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9

jamshaid
Mon Apr 23, 2018 5:08 pm
[RogerClark – Mon Apr 23, 2018 11:55 am] –
So the information about the blink rate was incorrect

The Blink sketch would flash on and off, faster than 1 second period

Also USB won’t work.

I recall someone else with a 12MHz board. So you could search to see what they did

Basically you need a custom Variant and change the PLL multiplier to x 6 rather than x 9

Thanks for the help sorry but the blink code was fine i tested it in comparision with my uno
I could have hooked my board to oscilloscope and shoud have seen the delay but my bad and I apologise and i do remember the usb wasnot working.
After the fix the serial is working ok �� thank you everyone for the help


jamshaid
Mon Apr 23, 2018 5:09 pm
[madias – Mon Apr 23, 2018 12:28 pm] –
Ok, this was a hard nut!
What Roger means:
–>
https://github.com/rogerclarkmelbourne/ … _setup.cpp
Line #54: change
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9

stevestrong
Mon Apr 23, 2018 5:34 pm
Your figures posted here viewtopic.php?f=3&t=3520#p44229 were misleading, I thought that you are using a blue pill, but you are instead using a custom board, right?

Next time please give actual and correct information.


madias
Mon Apr 23, 2018 5:44 pm
[stevestrong – Mon Apr 23, 2018 5:34 pm] –
Your figures posted here viewtopic.php?f=3&t=3520#p44229 were misleading, I thought that you are using a blue pill, but you are instead using a custom board, right?

Next time please give actual and correct information.

Next time we should all cry:
“REAL photo or it didn’t happen!”


Leave a Reply

Your email address will not be published. Required fields are marked *