我刚刚改了一下,USART2发,USART3接收,涛声依旧。
1通道是探针,每次进入USART2中断,反转一次
2是总线数据波形
以下是初始化代码,另一通道一样:
USART_InitStructure.USART_BaudRate = 500000;
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_ITConfig(USART2, USART_IT_RXNE, ENABLE);
USART_Cmd(USART2, ENABLE);
USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);
以下是USART2接收中断代码,3通道类似:
void USART2_IRQHandler(void) // IO Module
{
u16 temp=0;
USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
GPIO_WriteBit(GPIOC, GPIO_Pin_9, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_9)));
if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET
/*&& USART_GetFlagStatus(USART2, USART_FLAG_ORE) == RESET
&& USART_GetFlagStatus(USART2, USART_FLAG_NE) == RESET
&& USART_GetFlagStatus(USART2, USART_FLAG_FE) == RESET */ )
{
temp=*((vu32*)0x40004404);
TIM_ITConfig(TIM2, TIM_IT_CC2, DISABLE);
temp=USART_ReceiveData(USART2);
/* Overwrite protect */
RxBuff_IO[RxBuffWrPt_IO++]=(u8)temp;
if(RxBuffWrPt_IO>=RX_BUFF_SIZE_IO)
{
IO_CommStatus=130;
RxBuffWrPt_IO--;
}
else IO_CommStatus = 4; // Reciving...
temp = TIM_GetCounter(TIM2); // Wait for Slave
TIM_SetCompare2(TIM2, temp + IO_COMM_IDLE); // 3.5bytes for recive end
TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);
}
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
}
接收方USART3未见回应。
!真心感谢楼上兄弟! |