cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f100 usart not working properly

kkada
Associate II

Hi,

I am working on stm32f100 48 pin device.I am having operational issue while working on usart.

my hw configured to use internal hsi osc which further add pll to generate sysclk of 36Mhz.I am communicating to gsm module over usart3.issue is gsm module not accepting any commands.though i can see responses from module when power on/off.so i tried using loop back test on controller.i found in live watch some data is getting skipped.

other way round i also tested using cp2102 usb to ttl module to check if micro controller transmits command or not.on putty i dont see any commands from controller.

my question---what is maximum clock can be generated using hsi?

how much we can rely on internal osc integrity?? as you suggest some calibration methods

internal osc setting affect baud rate generator?

I have checked gsm module using cp2102 and its working pretty fine.

thanks .

kiran kadam

10 REPLIES 10
kkada
Associate II

development env used IAR 7.3 ,jtag,STM32 standard lib

T J
Lead

I don't have any issues with the baud rate, hardly ever use a crystal these days, always using 230400 to Terraterm.

" Data being skipped " You have to use the DMA Uart function, and never lose another byte.

HSI is supposed to be maximum:

Based on the ARM Cortex-M3 core running at up to 24 MHz

it is a ValueLine processor...

The F1 series should be able to use HSI+PLL to run at up to 64 MHz

Serial comms can tolerate a lot of baud rate mismatch, +/-3% would certainly be tolerable.

Perhaps look if the USART is flagging framing, overrun, etc type conditions, and clear those. Don't monitor the USART peripheral directly in the debug view, it will interfere with its operation.

Internal clocks can be routed out the PA8/MCO pin to a scope. If you're clocking the part with HSI+PLL the speed/stability should be reflected on all TIM output pins.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kkada
Associate II

Hi all,

let me thank you first for providing quick support.coming back to query I am sharing files having code which has issue.kindly review it for changes are done properly or not.

@Community member​  "Perhaps look if the USART is flagging framing, overrun, etc type conditions, and clear those. Don't monitor the USART peripheral directly in the debug view, it will interfere with its operation." ---checked already ....not an issue

"Internal clocks can be routed out the PA8/MCO pin to a scope"---->would love to have ...but dont have scope

if usart only configured for reception then interrupt on rx line continuously generates.

note : I have shorted rx and tx now just for checking what i am transmitting and what is receiving actual.

Thanks.

Really can't spend time trawling through volumes of code

 USART_ClearFlag(USART3, USART_IT_TXE); // << _IT_ is not _FLAG_

 USART_ITConfig(USART3, USART_IT_TXE, DISABLE);

USART_ClearFlag(USART3,USART_FLAG_ORE||USART_FLAG_FE||USART_FLAG_NE || USART_FLAG_PE); // Inappropriate use of II

Don't really see you sensing/clearing error states properly

GSM Modems frequently need flow control, and don't tolerate new commands while busy, some network interactions may take multiple minutes, sending new commands may be ignored, or cause an abort.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kkada
Associate II

@Community member​  apologizing for sharing wrong file.

"USART_ClearFlag(USART3,USART_FLAG_ORE||USART_FLAG_FE||USART_FLAG_NE || USART_FLAG_PE); "---redundant code was there which i removed earlier.

USART_ClearFlag(USART3, USART_IT_TXE)----will update this and let you know results.

gsm modem perspective i have disconnected modem now.just working on loopback test on micro controller first to enable usart working properly.

max clock can run on cortex m3 24mhz confirmed using cubemx clock configurator

flow control not implemented in hardware as keeping requirement no bulk data will be exchanged

thanks

kkada
Associate II

hi @Community member​  changes done as you said but didn't work out either.surely clock config only messing here.but how that i cant yet fix.any other suggestions that you would like to add.

thanks

No

Have you ruled out the clocking by checking bit timings, and internal clocks?

If the signalling is all valid you'll want to focus on your interaction with the GSM modem, logging TX/RX traffic in the time domain. I'd probably start by tunnelling a USART connection across the STM32 so I could talk to the modem via a PC terminal. Then walk it through the interactions you're previously tried to automate.

GSM modems draw a lot of power, make sure your supplies are adequate and things aren't browning out.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kkada
Associate II

Hi @Community member​  due to shortcoming of equipment couldn't figure out bit timings as you mentioned.so as of now digging with schematic check ,serial monitor data check etc. please confirm once about my perception ,loop-back test that i am trying to run on micro controller ...practically is possible or not??i mean to say i have directly shorted tx ,rx line as per null modem connection or does ii require piece of hardware intermittent. please confirm.meanwhile i take a look on any findings on clocking.

thanks