2012-02-13 11:16 AM
Hello,
I have a little problem with Rx on stm32f417.I designed my own board, byt i am putting this here, becouse i cannot find another approperiate forum.I tried to set up UART2, but i cannot make reciving working.HW is OK, i tested that.void USART_Inicializace(void){ GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure2; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); // 1. RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE); // 2. GPIO_PinAFConfig ( GPIOD, GPIO_PinSource5 , GPIO_AF_USART2) ; GPIO_PinAFConfig ( GPIOD, GPIO_PinSource6 , GPIO_AF_USART2) ; // // // Tx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // alternate function! GPIO_InitStructure.GPIO_OType = GPIO_OType_PP ; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure);////// // Rx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_Init(GPIOD, &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; USART_Init(USART2, &USART_InitStructure);// USART_Cmd(USART2, ENABLE); // jeste zbyva konfigurace preruseni// NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//// NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;// NVIC_Init(&NVIC_InitStructure);// USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);}Thank you.2013-04-24 03:57 AM
I think I highlighted the problem... I try my code with IAR (because I'm on
Coocox, ARM toolchain) and it works !
It's seems that with Coocox, my MIDI frames are sent with the wrong baudrate
(because on the scope I can see the datarate is slower than the MIDI from my
synth).
I don't know what to do, because in IAR and in Coocox I have the same code and the samesystem_stm32f4xx.c...
2013-04-24 04:30 AM
Check the project's meta data for defines sent to the compilers command line, HSE_VALUE being a primary culprit for mismatched baud rates. Check also the PLL settings correlate with the crystal on your board.
2013-04-24 04:46 AM
I just check with a scope, my STM32 is working at 8MHz !! (Instead of 144Mhz)
Do you know how can check the project's meta data ? I'm not familiar with this...2013-04-24 06:10 AM
It's all the stuff under the ''Options'' for a project, probably the C/C++ tabs or whatever the equivalent is in IAR vs CooCox.
Where the project files are ASCII text (ie XML, etc) you can also comb through them, or makefiles if the tools can generate those.