2013-11-12 07:38 AM
Hello,
I'm using a SM3210e-Eval board with ahttp://www.mikrocontroller.net/part/STM32F103
Z processor fromhttp://www.mikrocontroller.net/articles/ARM
and I'm a newbie . I dont really get why but if I send I getting a different value on my Terminal (hterm) Example:I'm sending 0x49 but get 8698 (Hex)
I'm sending 'A' but get FE06 (Hex)
I'm sending '0' but get F800 (Hex)
I'm not sure but do I need to change some clockspeed in the SystemInit() ? But which one and how much ? I'm really lost....trying since 2 days solve this problem...USART_InitTypeDef USART_InitStructure;
void
main(void
) { SystemInit(); Init(); Config_ADC(); Config_Usart(); ...while
(1
) { USART_SendData(USART1,0x49
);//
/* Loop until the end of transmission */
while
(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { } } }void
Config_Usart() {//enable bus clocks
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);/* Configure USART2 Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate =9600
; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;/* Configurating and enabling USART1 */
USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE); } #stm3210e-eval #usart2013-11-12 07:54 AM
Sounds like a timing problem. Have you looked at the signal with a scope? Confirmed bit timing?
Most likely a project level disagreement between the define HSE_VALUE and the crystal on the board. What tool chain? Normally SystemInit() is called prior to main() being called. You using CooCox? What if you don't call SystemInit(), or comment out it's body? This should run the board at 8 MHz from the HSI clock source. Does that work?2013-11-12 08:29 AM
I'm using Keil as toolchain. And I already selected there my device SM32F103ZG.
You mean comment out in file system_stm32f10x.c ? Or just in my main() ?2013-11-12 09:30 AM
If you're using the v3.5.0 CMSIS version of the firmware library, SystemInit() should have been called in startup_stm32f10x_xx.s, you should not be calling in again in main().
The quickest way to get the board to run from HSI would be to comment out the body code for SystemInit() in system_stm32f10x.c ie void SystemInit(void) { #if 0 // .. Body thereof #endif } Check what value you have for HSE_VALUE within your project's pre-processor defines, or perhaps stm32f10x_conf.h2013-11-13 04:16 AM
Hey commented out the SystemInit() body and it worked.!!!! THANKS !!!
That means the mistake was there .... so next step ist to change the SystemInit ? Or can I solve the problem in a other way ?2013-11-13 07:40 AM
My preprocessor Symbols has defined STM32F10X_HD_VL
The SetSysClock() function in SystemInit is the problem in the system_stm32f10x.c: #if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL) /* #define SYSCLK_FREQ_HSE HSE_VALUE */ #define SYSCLK_FREQ_24MHz 24000000 #else /* #define SYSCLK_FREQ_HSE HSE_VALUE */ /* #define SYSCLK_FREQ_24MHz 24000000 */ /* #define SYSCLK_FREQ_36MHz 36000000 */ /* #define SYSCLK_FREQ_48MHz 48000000 */ /* #define SYSCLK_FREQ_56MHz 56000000 */ #define SYSCLK_FREQ_72MHz 72000000 #endif ..... static void SetSysClock(void) { #ifdef SYSCLK_FREQ_HSE SetSysClockToHSE(); #elif defined SYSCLK_FREQ_24MHz SetSysClockTo24(); #elif defined SYSCLK_FREQ_36MHz SetSysClockTo36(); #elif defined SYSCLK_FREQ_48MHz SetSysClockTo48(); #elif defined SYSCLK_FREQ_56MHz SetSysClockTo56(); #elif defined SYSCLK_FREQ_72MHz SetSysClockTo72(); #endif /* If none of the define above is enabled, the HSI is used as System clock source (default after reset) */ }2013-11-13 07:59 AM
It is critical for you to understand the crystal on your board, and the value defined for HSE_VALUE within you project.
Suggest using your working HSI USART example, and printing out the value of HSE_VALUE the project is built with.2013-11-13 08:21 AM
my HSE_VALUE is 8000 000 i tried to make a preprocessor Symbol define in my Keil: HSE_VALUE=8000000
but it didnt worked... I also run an ADC on my board , when the SystemInit() is comment everything slows down like my ADC but my USART works well.... Is there a way to solve this ?2013-11-13 08:37 AM
Have you tried using some of the template projects for your board included in the firmware library, and USB examples?