首先我在F030系列生成的代码中,没有看到回调函数的调用. HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) { /* Check that a Rx process is not already ongoing */ if(huart->RxState == HAL_UART_STATE_READY) { if((pData == NULL ) || (Size == 0U)) { return HAL_ERROR; }
/* In case of 9bits/No Parity transfer, pData buffer provided as input paramter should be aligned on a u16 frontier, as data to be received from RDR will be handled through a u16 cast. */ if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE)) { if((((uint32_t)pData)&1U) != 0U) { return HAL_ERROR; } }
/* Process Locked */ __HAL_LOCK(huart);
huart->pRxBuffPtr = pData; huart->RxXferSize = Size; huart->RxXferCount = Size;
/* Computation of UART mask to apply to RDR register */ UART_MASK_COMPUTATION(huart);
huart->ErrorCode = HAL_UART_ERROR_NONE; huart->RxState = HAL_UART_STATE_BUSY_RX;
/* Process Unlocked */ __HAL_UNLOCK(huart);
/* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */ SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
/* Enable the UART Parity Error and Data Register not empty Interrupts */ SET_BIT(huart->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
return HAL_OK; } else { return HAL_BUSY; } }
然后我在while循环之前开启中断 HAL_UART_Receive_IT(&huart2,Rx_Buf,1); 确定Rx_Buf可以接到数据,但是我在回调函数里转存数据的时候,就无法转存过去 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart) { Zigbee_Buf[R_Count++]=Rx_Buf[0]; HAL_UART_Receive_IT(&huart2,Rx_Buf,1); } Zigbee_Buf这个数组里一直没数据...而且我只能接收到第一次发送的一个字节的数据,第二次发另外的数据就接收不到了,..不知道问题出在哪里了.有没有人懂这个的,..点拨一下
|