[mw_shl_code=c,true]/* USER CODE BEGIN 0 */
uint8_t data[16]="hello";
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_UART7_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_WritePin(GPIOE,DE_Pin, GPIO_PIN_SET); //使能RS485 发送端DE
// while(HAL_UART_GetState(&huart7) == HAL_UART_STATE_RESET );
HAL_UART_Transmit(&huart7,data,1,100); //发一个字节的数据出去
//while(HAL_UART_GetState(&huart7) == HAL_UART_STATE_RESET );
while(__HAL_UART_GET_FLAG(&huart7,UART_FLAG_TC)!= SET);//等待发送结束
HAL_GPIO_WritePin(GPIOE,DE_Pin, GPIO_PIN_RESET);
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>