AnsweredAssumed Answered

stm32f302 usart interrupt problem

Question asked by jie.li.002 on Apr 1, 2015
Latest reply on Apr 1, 2015 by jie.li.002
Hi all, I configure my stm32f302's usart without peripheral lib, when i enable it with CR1->UE, the usart interrupt keep triggered and CR1->UE bit cleared automatically, actually i didn't connect anything to RX and TX pin.
My code here:
01.void USART1_IRQHandler(void)
02.{
03.    Uart_gp_slave_uart_event(&uart_gp_slave);
04.}
05. 
06.void Uart_gp_slave_uart_event(struct _s_uart_gp_slave *uart)
07.{
08.    uint32_t isr = uart->UART->ISR;
09.     
10.    uart->UART->ICR = LITERAL_BIN32(00000000,00010010,00011011,01011111);
11. 
12.    if( isr & USART_ISR_TC )
13.    {
14.        RO_DMA_CLR_ISR(uart->DMA, uart->DMA_TX_CH_INDEX);
15.        uart->DMA_TX_CH->CCR &= ~DMA_CCR_EN;
16.        uart->state = UART_GP_SLAVE_TX_IDLE;
17.    }
18.    if( isr & USART_ISR_IDLE )
19.    {
20.        RO_DMA_CLR_ISR(uart->DMA, uart->DMA_RX_CH_INDEX);
21.        uart->rx_done_callback(uart->rxLength - uart->DMA_RX_CH->CNDTR);
22.        uart->DMA_RX_CH->CCR &= ~DMA_CCR_EN;
23.        uart->DMA_RX_CH->CNDTR = uart->rxLength;
24.        uart->DMA_RX_CH->CCR |= DMA_CCR_EN;
25.    }
26.}
27. 
28.void Uart_gp_slave_abstract_ini(struct _s_uart_gp_slave *uart)
29.{
30.    NVIC_InitTypeDef NVIC_InitStruct;
31.     
32.    //GPIO ini
33.    Ro_gpio_setup( uart->GPIO_TX, uart->GPIO_TX_Pin,
34.                                 RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
35.    Ro_gpio_setup( uart->GPIO_RX, uart->GPIO_RX_Pin,
36.                                 RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
37.    Ro_gpio_setup( uart->GPIO_DE, uart->GPIO_DE_Pin,
38.                                 RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
39.     
40.    Ro_gpio_af_setup(uart->GPIO_TX, uart->GPIO_TX_Pin, uart->GPIO_AF_TX);
41.    Ro_gpio_af_setup(uart->GPIO_RX, uart->GPIO_RX_Pin, uart->GPIO_AF_RX);
42.    Ro_gpio_af_setup(uart->GPIO_DE, uart->GPIO_DE_Pin, uart->GPIO_AF_DE);
43. 
44.    //UART ini
45.    uart->UART->CR1 = LITERAL_BIN32(00000011,11111111,00000000,01011100);
46.    uart->UART->CR2 = LITERAL_BIN32(00000000,00000000,00000000,00000000);
47.    uart->UART->CR3 = LITERAL_BIN32(00000000,00000000,01000000,11000001);
48. 
49.        uart->UART->BRR = 0x12; // 4MBps
50.     
51.    //DMA ini
52.    uart->DMA_TX_CH->CCR = LITERAL_BIN32(00000000,00000000,00000000,10011000);
53.    uart->DMA_TX_CH->CPAR = (uint32_t)(&(uart->UART->TDR));
54.     
55.    uart->DMA_RX_CH->CCR = LITERAL_BIN32(00000000,00000000,00000000,10001000);
56.    uart->DMA_RX_CH->CPAR = (uint32_t)(&(uart->UART->RDR));
57.     
58.    // UART interrupt
59.    NVIC_InitStruct.NVIC_IRQChannel = uart->UART_IRQ;
60.       NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1;
61.       NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
62.       NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
63.       NVIC_Init(&NVIC_InitStruct);
64.     
65.    uart->UART->CR1 |= USART_CR1_UE;
66.}


Outcomes