AnsweredAssumed Answered

STM32F3

Question asked by k.kvresto on Mar 3, 2016
Latest reply on Mar 4, 2016 by k.kvresto
I've had a quick look around and I cant find too much on USART3 fro the STM32F3 series. I have modified the std STM32F3 demo
app that can be downloaded, and I'm currently using USART1 for serial coms. I now want to switch to USART3 and after
changing all references from USART1 to USART3, and a couple of other defines, I still cant get it to work. Below is my setup,
can anyone help?

1) 1st I setup the parameters before calling STM_EVAL_COMInit()
              USART_InitTypeDef USART_InitStructure;
              NVIC_InitTypeDef NVIC_InitStructure;

              /* Setup the USART interrupt vector*/
              NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM3_IRQn;
              NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
              NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
              NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
              NVIC_Init(&NVIC_InitStructure);

              USART_InitStructure.USART_BaudRate = 115200;
              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;

              STM_EVAL_COMInit(COM1, &USART_InitStructure);
              STM_EVAL_COMInit(COM3, &USART_InitStructure);

              /* Enable the USARTx Receive interrupt: this interrupt is generated when the
                 USARTx receive data register is not empty */
              USART_ITConfig(EVAL_COM3, USART_IT_RXNE, ENABLE);



2) STM_EVAL_COMInit() is just the standard code which I've seen in so many ST demo apps:
            void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct)
            {
              GPIO_InitTypeDef GPIO_InitStructure;

              /* Enable GPIO clock */
              RCC_AHBPeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM], ENABLE);

              /* Enable USART clock */
              RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE);

              /* Connect PXx to USARTx_Tx */
              GPIO_PinAFConfig(COM_TX_PORT[COM], COM_TX_PIN_SOURCE[COM], COM_TX_AF[COM]);

              /* Connect PXx to USARTx_Rx */
              GPIO_PinAFConfig(COM_RX_PORT[COM], COM_RX_PIN_SOURCE[COM], COM_RX_AF[COM]);

              /* Configure USART Tx as alternate function push-pull */
              GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM];
              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
              GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
              GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
              GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
              GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure);

              /* Configure USART Rx as alternate function push-pull */
              GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM];
              GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure);

              /* USART configuration */
              USART_Init(COM_USART[COM], USART_InitStruct);

              /* Enable USART */
              USART_Cmd(COM_USART[COM], ENABLE);
            }


3) below are my defines for USART3:
            #define EVAL_COM3                        USART3
            #define EVAL_COM3_CLK                    RCC_APB1Periph_USART3

            #define EVAL_COM3_TX_PIN                 GPIO_Pin_10
            #define EVAL_COM3_TX_GPIO_PORT           GPIOB
            #define EVAL_COM3_TX_GPIO_CLK            RCC_AHBPeriph_GPIOB
            #define EVAL_COM3_TX_SOURCE              GPIO_PinSource10
            #define EVAL_COM3_TX_AF                  GPIO_AF_7

            #define EVAL_COM3_RX_PIN                 GPIO_Pin_11
            #define EVAL_COM3_RX_GPIO_PORT           GPIOB
            #define EVAL_COM3_RX_GPIO_CLK            RCC_AHBPeriph_GPIOB
            #define EVAL_COM3_RX_SOURCE              GPIO_PinSource11
            #define EVAL_COM3_RX_AF                  GPIO_AF_7

            #define EVAL_COM3_IRQn                   USART3_IRQn           


BTW: I've modified the rest of it as well, ie

const

 

uint32_t COM_TX_PORT_CLK[COMn] = {EVAL_COM1_TX_GPIO_CLK,EVAL_COM2_TX_GPIO_CLK,EVAL_COM3_TX_GPIO_CLK};

 


Outcomes