在使用ST官网的例程X-CUBE-SPN7的UART_UI文件时,发现不知道该怎么通过串口大师来发正确的指令。 åä»ä¹é½æ²¡ååº 判断条件里有个Get_UART_Data() == 266 ,这个Get_UART_Data()只是返回 (UART.Instance->RDR); 这个266不知道怎么来的。有没有哪位高人指导一下? void UART_Set_Value() { if(Get_UART_Data() == 266 && (huart2.State != HAL_UART_STATE_BUSY_TX && huart2.State != HAL_UART_STATE_BUSY_TX_RX)) { if(Uart_cmd_flag == 0) { CMD_Parser((char*)aRxBuffer); } else { SIXSTEP_parameters.Uart_value_to_set = UART_num_decode(); switch(SIXSTEP_parameters.Uart_cmd_to_set) { case SETSPD_CMD: /*!< Set the new speed value command received */ PI_parameters.Reference = SIXSTEP_parameters.Uart_value_to_set; SIXSTEP_parameters.Ramp_Start = 1; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; huart2.State = HAL_UART_STATE_READY; break; case INIREF_CMD: /*!< Set the new STARUP_CURRENT_REFERENCE value command received */ SIXSTEP_parameters.Ireference = SIXSTEP_parameters.Uart_value_to_set; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case POLESP_CMD: /*!< Set the Pole Pairs value command received */ SIXSTEP_parameters.NUMPOLESPAIRS = SIXSTEP_parameters.Uart_value_to_set; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case ACCELE_CMD: /*!< Set the Accelleration for Start-up of the motor command received */ SIXSTEP_parameters.ACCEL = SIXSTEP_parameters.Uart_value_to_set; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case DIRECT_CMD: /*!< Set the motor direction */ SIXSTEP_parameters.CW_CCW = SIXSTEP_parameters.Uart_value_to_set; MC_Set_PI_param(&I_parameters); BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case KP_PRM_CMD: /*!< Set the KP PI param command received */ PI_parameters.Kp_Gain = SIXSTEP_parameters.Uart_value_to_set; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case KI_PRM_CMD: /*!< Set the KI PI param command received */ PI_parameters.Ki_Gain = SIXSTEP_parameters.Uart_value_to_set; BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; break; case POTENZ_CMD: /*!< Enable Potentiometer command received */ BUFF_RCV = RXBUFFERSIZE; Uart_cmd_flag = 0; huart2.State = HAL_UART_STATE_READY; HAL_UART_Transmit(&huart2, (uint8_t *)rowLxBuffer, (COUNTOF(rowLxBuffer) - 1),500); UART_FLAG_RECEIVE = TRUE; SIXSTEP_parameters.Potentiometer = SIXSTEP_parameters.Uart_value_to_set; break; } /* switch case */ } /* else */ } /* if */ |
STM32F3 硬件I2C 驱动OLED 求助!!
STM32F303使用定时器触发双ADC常规同步采样模式
哪位大哥传下STM32F334 Nucleo的工程模板给我下
STM32F334 不能串口下载
关于STM32F334的HRTIM分辨率问题
STM32F303+LCD1602程序问题,不只为什么点不亮?
STM32F334的ADC使用问题
STM32F334 HRTIM形成移相全桥波形问题
有用过STM32F373VC的板子么 iic 例程不好使
STM32F3 ADC外部触发采样达不到7.2MSPS
你的图中不是很清楚吗?STATUS, DIRICT CW/CCW等
你的字符能显示,波特率什么的应该没有问题。然后就是发送的是ASCII码,这页没有问题。问题可能是需不需要换行了,什么的。
另一个可能的问题是你的串口工具不支持交互操作。你可以试试Putty
因为RDR的值不可能是266啊,最大也不过255.
个人还是不怎么习惯使用这种库