通过串口与PC机实现通信,pc机发送的数据,通过串口单片机可以接收到,但是单片机向pc机发送数据时,串口助手不显示发送的数据,用printf可以打印出来数据,这是什么情况?
int main(void)
{
uint8_t adcx,i=0,temp[1]={0};
float temp1,temp2,temp3;
// uint8_t len;
HAL_Init();
DacHandle.Instance = DAC;
/* Configure LED3, LED4, LED5 and LED6 */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
BSP_LED_Init(LED5);
BSP_LED_Init(LED6);
/* Configure the system clock to 168 MHz */
SystemClock_Config();
uart_init(9600);
MY_ADC_Init();
/* Initialize MEMS Accelerometer mounted on STM32F4-Discovery board */
if(BSP_ACCELERO_Init() != ACCELERO_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Turn ON LED4: start of application */
BSP_LED_On(LED4);
/* Configure TIM4 Peripheral to manage LEDs lighting */
TIM_LED_Config();
/* Configure USER Button */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
BSP_PB_Init1(BUTTON_KEY1, BUTTON_MODE_EXTI1);
/* Turn OFF all LEDs */
LEDsState = LEDS_OFF;
GetLockCode();
HAL_DAC_DeInit(&DacHandle);
DAC_Ch1_TriangleConfig(1400);
BSP_AUDIO_IN_Init(12500, DEFAULT_AUDIO_IN_BIT_RESOLUTION, DEFAULT_AUDIO_IN_CHANNEL_NBR);
BSP_AUDIO_IN_Record((uint16_t*)&InternalBuffer[0], 96);//128
WavePlayerInit(12500);
wav_buffill(pp1,16,16);
BSP_AUDIO_OUT_Play((uint16_t*)pp1, 8);
while(1)
{
switch(CL)
{
case 0XA0:
WaveRecorderProcess0();
break;
case 0XA1:
WaveRecorderProcess1();
break;
case 0XA2:
WaveRecorderProcess2();
break;
case 0XA3:
WaveRecorderProcess3();
break;
case 0XA4:
WaveRecorderProcess4();
break;
case 0XA5:
WaveRecorderProcess5();
break;
case 0XA6:
WaveRecorderProcess6();
break;
case 0XA7:
WaveRecorderProcess7();
break;
case 0XB0:
DAC_Ch1_TriangleConfig(5*280);
break;
case 0XB1:
DAC_Ch1_TriangleConfig(6*280);
break;
case 0XB2:
DAC_Ch1_TriangleConfig(7*280);
break;
case 0XB3:
DAC_Ch1_TriangleConfig(8*279);
break;
case 0XB4:
DAC_Ch1_TriangleConfig(9*279);
break;
case 0XB5:
DAC_Ch1_TriangleConfig(10*279);
break;
case 0XB6:
DAC_Ch1_TriangleConfig(11*279);
break;
case 0XB7:
DAC_Ch1_TriangleConfig(12*279);
break;
case 0XB8:
DAC_Ch1_TriangleConfig(13*279);
break;
case 0XB9:
DAC_Ch1_TriangleConfig(14*279);
break;
case 0XCC:
adcx=Get_Adc_Average(ADC_CHANNEL_8,20);
temp[0]=(float)adcx*(3.0/4096);
// temp1=(float)temp/99.4/5;
// printf("
Äú·¢ËíμÄÏûÏ¢Îa:
");
HAL_UART_Transmit(&UART2_Handler,(uint8_t*)temp,1,1000); //·¢Ëí½óêÕμ½μÄêy¾Y
while(__HAL_UART_GET_FLAG(&UART2_Handler,UART_FLAG_TC)!=SET); //μè′y·¢Ëí½áêø
// printf("
");//2åèë»»DD
USART_RX_STA=0;
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>