cancel
Showing results for 
Search instead for 
Did you mean: 

serial port debug question

joemccarr
Senior
Posted on December 12, 2015 at 16:29

Hello All,

Moving from the Motorolla 9s12 to the stm32.  Just got a eval board and after recovering from Register shock I am just trying to get some blinky lights and serial comm (USART) going which is what I would normally use as my debugger : )

Having a problem getting usart to work. Nothing showing up on my pc via hyperterm.

Using the debugger is it possible to see what goes in the USART data register or is that shifted out so quick one would only see 0. ?

Thanks and enjoy

#usart #debugger-stm32
8 REPLIES 8
rwmao
Senior
Posted on December 12, 2015 at 18:50

If you use CDC/VCP of usb to do debugging, you can follow the example I built: 

https://bitbucket.org/rwmao/cdc_onstm32f411rc/wiki/Home

It is really simple. Plug in USB to computer, and run a program(attached on above website), chip can send chars to computer.

You can check the snapshots. 

https://bitbucket.org/rwmao/cdc_onstm32f411rc/src/12de104e5bb561881af2c471d97ab3d46b30f6b4?at=master

let me elaborate a little bit more.

USART debug uses comm port to exchange data. You can also use USB as a virtual comm port to exchange data between computer and chip.

For most developing board, there are two usb ports, one is for programming (SWD) and another is USB for data,which can be a usb host,device,cdc or others.

Posted on December 12, 2015 at 21:20

Let's start with with what STM32, on what Board, and try and narrow this down a tad.

The debugger cannot give you a view inside the peripherals. The register you write data to the USART is not the same register as you read back, even if at the same address, or very quickly afterward. Reading the data register so the debugger can show it to you clears/alters bits in the status register. The debugger doesn't have magic access to hardware, and tends to be invasive.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
joemccarr
Senior
Posted on December 12, 2015 at 23:02

My board uses the stm32f105rc. I got the board from imagecraft C. the rx,tx lines go thru a

FT230XS usb chip to the pc.  When I step thru my code I do get some characters appearing on the  terminal but its garbage. I do not have my scope up and running so I cant look at the

clock that drives usart 1 but looking at the rcc registers I am running at 72 MHz.

Calculated baud is   baud=72MHz/57600 . This should not be taking me this long to get to work but up side is making me go thru the documentation and understanding the controller.

I will post code if I can not get it talking fairly soon. Thanks for your help.

Posted on December 13, 2015 at 00:27

The biggest trap here is HSE_VALUE, it should be defined to match the physical oscillator speed so the math to compute the rates works properly. In most STM32 it's generally set for 8 MHz, I suspect a 105/107 board might use 25 MHz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
joemccarr
Senior
Posted on December 13, 2015 at 00:59

Yes, you are correct about that! stm32f10x.h had the hclk defined as 25MHz. I previously changed that define to 8MHz to reflect the part on my board. I may have to try another terminal program or computer to see if that works.  Thanks for your help, again.

rwmao
Senior
Posted on December 13, 2015 at 22:40

You can try this terminal:

https://bitbucket.org/rwmao/cdc_onstm32f411rc/src/12de104e5bb561881af2c471d97ab3d46b30f6b4/Com%20Debug%20Assist/?at=master

it looks like I am selling software ):. It is free. I used it to debug CDC(USB). it is a good tool to use.

joemccarr
Senior
Posted on December 14, 2015 at 20:31

I moved my development to a different computer and now the program works.

I really hate those type of problems. Ugh...

joemccarr
Senior
Posted on December 15, 2015 at 12:31

I downloaded the latest version of tera term now all is working on the original computer. Time to get on with learning this controller.