2015-03-31 06:31 PM
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->UEbit cleared automatically, actually i didn't connect anything to RX and TX pin.
My code here:
void
USART1_IRQHandler(
void
)
{
Uart_gp_slave_uart_event(&uart_gp_slave);
}
void
Uart_gp_slave_uart_event(
struct
_s_uart_gp_slave *uart)
{
uint32_t isr = uart->UART->ISR;
uart->UART->ICR = LITERAL_BIN32(00000000,00010010,00011011,01011111);
if
( isr & USART_ISR_TC )
{
RO_DMA_CLR_ISR(uart->DMA, uart->DMA_TX_CH_INDEX);
uart->DMA_TX_CH->CCR &= ~DMA_CCR_EN;
uart->state = UART_GP_SLAVE_TX_IDLE;
}
if
( isr & USART_ISR_IDLE )
{
RO_DMA_CLR_ISR(uart->DMA, uart->DMA_RX_CH_INDEX);
uart->rx_done_callback(uart->rxLength - uart->DMA_RX_CH->CNDTR);
uart->DMA_RX_CH->CCR &= ~DMA_CCR_EN;
uart->DMA_RX_CH->CNDTR = uart->rxLength;
uart->DMA_RX_CH->CCR |= DMA_CCR_EN;
}
}
void
Uart_gp_slave_abstract_ini(
struct
_s_uart_gp_slave *uart)
{
NVIC_InitTypeDef NVIC_InitStruct;
//GPIO ini
Ro_gpio_setup( uart->GPIO_TX, uart->GPIO_TX_Pin,
RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
Ro_gpio_setup( uart->GPIO_RX, uart->GPIO_RX_Pin,
RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
Ro_gpio_setup( uart->GPIO_DE, uart->GPIO_DE_Pin,
RO_GPIO_MODE_AF, RO_GPIO_OUT_PP, RO_GPIO_SP_HIGH, RO_GPIO_PULL_NO);
Ro_gpio_af_setup(uart->GPIO_TX, uart->GPIO_TX_Pin, uart->GPIO_AF_TX);
Ro_gpio_af_setup(uart->GPIO_RX, uart->GPIO_RX_Pin, uart->GPIO_AF_RX);
Ro_gpio_af_setup(uart->GPIO_DE, uart->GPIO_DE_Pin, uart->GPIO_AF_DE);
//UART ini
uart->UART->CR1 = LITERAL_BIN32(00000011,11111111,00000000,01011100);
uart->UART->CR2 = LITERAL_BIN32(00000000,00000000,00000000,00000000);
uart->UART->CR3 = LITERAL_BIN32(00000000,00000000,01000000,11000001);
uart->UART->BRR = 0x12;
// 4MBps
//DMA ini
uart->DMA_TX_CH->CCR = LITERAL_BIN32(00000000,00000000,00000000,10011000);
uart->DMA_TX_CH->CPAR = (uint32_t)(&(uart->UART->TDR));
uart->DMA_RX_CH->CCR = LITERAL_BIN32(00000000,00000000,00000000,10001000);
uart->DMA_RX_CH->CPAR = (uint32_t)(&(uart->UART->RDR));
// UART interrupt
NVIC_InitStruct.NVIC_IRQChannel = uart->UART_IRQ;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);
uart->UART->CR1 |= USART_CR1_UE;
}
#usart #stm32f3 #stm32
2015-03-31 09:34 PM
You look to enable the Idle interrupt.
2015-03-31 10:26 PM
thanks for your reply, clive1.
yes, i want to use idle interrupt to detect rx frame endbut i think idle interrupt would not keep trigger when rx is idle because i had used stm32f4's usart idle interrupt before, it just triggered one time after one frame