cancel
Showing results for 
Search instead for 
Did you mean: 

Cortex-M3 USART woes (still)

alexsardo9
Associate II
Posted on April 03, 2010 at 03:10

Cortex-M3 USART woes (still)

11 REPLIES 11
Posted on May 17, 2011 at 13:45

I had tried the previously posted USART1 code fragment on an STM32F103RET device (512KB), there wasn't any other initialization of hardware from the boot vector to the main() function. So I'm pretty sure it represents the minimal requirements to actually get the USART to function.

Are you sure the code is actually downloaded and running? Can you step it along with a JTAG debugger? In Keil you can actually view the peripheral and clock settings.

The USART1 output pin shouldn't be floating. As you have wires to the Rx pin PA.10 you could try setting it as a PP GPIO output and bang it up and down to see if that is working in the loop. You could try something similar on PA.9 too. Do you have any other pins connected to LEDs or other signs-of-life type indicators which you could toggle?

You could perhaps try the code on an eval/dev board with the pins already wired to an RS232 interface.

-Clive

Edit: Not sufficiently familiar with IAR, but you might want to check the RAM and STACK settings for the project, or code in the startup.s (or whatever) that takes the boot vector/initial stack pointer. If something is wrong there the CPU will Hard Fault. You could evaluate this by debugging with a JTAG probe and walking through the code as it executes.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

I have a graphic routine that show life on an lcd. it runs before the USART init (your example) and it shows ok on the LCD. I even added an ICL3232 to amplify and stabilize PA9 - but I still see nothing on Pin14...0690X00000602hQQAQ.jpg

I can't believe that I can do anything on this board, load graphics, animation show pictures, read keys but I can't get the USART1 to work ...

It's a custom hand-held unit not the development board. it only had the STM chip, 8mhz crystal, LCD and a few buttons.

Maybe it's a faulty chip but I doubt it ... it's Friday so I'll keep at it a little longer since I'm not in the office tomorrow ...

I don't have JTAG I have an oscilloscope which I often use .. I can see life on many pins (meaning it's alive) but not on PA9, pin 68 of the STM

...
alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

I can write anything I want on the LCD ... (I have a function that I wrote as: PrintAT(x,y,color,str);

What do you suggest?

By the way I can validate that your code is correct since i found similar code on the ST site ... So I guess the problem may be in the vector init or somewhere along those lines ...

jjcote
Associate II
Posted on May 17, 2011 at 13:45

For starters, try displaying a counter on your LCD that's incremented in the while loop, to make sure that the code is getting that far and trying to send out characters.

alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

Did that -- counter running in the while loop.

jjcote
Associate II
Posted on May 17, 2011 at 13:45

And to be safe, make sure that the remap bit in AFIO isn't accidentally getting set.

alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

how can i do that (no JTAG) ...

alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

I spent some hours on this issue last night and I can't make any progress. All I can think is that perhaps there are some issue with the IAR initialization. I guess unless anyone else has any suggestions or complete USART1 example for IAR5 I'll need to get myself a JTAG and step it through ...

alexsardo9
Associate II
Posted on May 17, 2011 at 13:45

SUCCESS!

This morning I downloaded the ST example on USART and after changing the ICF (for my target hardware) it compiled and .....

Printf Example: retarget the C library printf function to the USART

USART1>

I got that text on the terminal !!!!

Whoohoo! I should now be able to compare all the init files to find out which one is different and where. I know it's not the ICF file, so perhaps the vector or another init .... not sure what the vector does yet but I'll learn...

Anyway thank you guys for providing me with working code which isolated the problem to INIT or HARDWARE ....

I'm very happy now and can put it all together to get this project finished in time.

Alex