Question
Sending data from stm32f4 to pc
Posted on March 24, 2013 at 20:27
hi,
i am trying to send data from accelerometer to pc using virtual com port ,but when i open hyper terminal to check if data was sent i found out unsignificant symbols!!!this is the systick handler wich is called when an interruption is generated void SysTick_Handler(void){ uint8_t temp1, temp2 = 0; if (TimingDelay != 0x00) { TimingDelay_Decrement(); } else { Counter ++; if (Counter == 10) { Buffer[0] = 0; Buffer[2] = 0; /* Disable All TIM4 Capture Compare Channels */ TIM_CCxCmd(TIM4, TIM_Channel_1, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_2, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_3, DISABLE); TIM_CCxCmd(TIM4, TIM_Channel_4, DISABLE); LIS302DL_Read(Buffer, LIS302DL_OUT_X_ADDR, 6); //routine used to send data via vcp!!! DISCOVERY_EXTI_IRQHandler(); /* Remove the offsets values from data */ Buffer[0] -= XOffset; Buffer[2] -= YOffset; /* Update autoreload and capture compare registers value*/ temp1 = ABS((int8_t)(Buffer[0])); temp2 = ABS((int8_t)(Buffer[2])); TempAcceleration = MAX(temp1, temp2); if(TempAcceleration != 0) { if ((int8_t)Buffer[0] < -2) { /* Enable TIM4 Capture Compare Channel 4 */ TIM_CCxCmd(TIM4, TIM_Channel_4, ENABLE); /* Sets the TIM4 Capture Compare4 Register value */ TIM_SetCompare4(TIM4, TIM_CCR/TempAcceleration); } if ((int8_t)Buffer[0] > 2) { /* Enable TIM4 Capture Compare Channel 2 */ TIM_CCxCmd(TIM4, TIM_Channel_2, ENABLE); /* Sets the TIM4 Capture Compare2 Register value */ TIM_SetCompare2(TIM4, TIM_CCR/TempAcceleration); } if ((int8_t)Buffer[2] > 2) { /* Enable TIM4 Capture Compare Channel 1 */ TIM_CCxCmd(TIM4, TIM_Channel_1, ENABLE); /* Sets the TIM4 Capture Compare1 Register value */ TIM_SetCompare1(TIM4, TIM_CCR/TempAcceleration); } if ((int8_t)Buffer[2] < -2) { /* Enable TIM4 Capture Compare Channel 3 */ TIM_CCxCmd(TIM4, TIM_Channel_3, ENABLE); /* Sets the TIM4 Capture Compare3 Register value */ TIM_SetCompare3(TIM4, TIM_CCR/TempAcceleration); } /* Time base configuration */ TIM_SetAutoreload(TIM4, TIM_ARR/TempAcceleration); /* Read click status register */ LIS302DL_Read(&ClickReg, LIS302DL_CLICK_SRC_REG_ADDR, 1); if(ClickReg == SINGLECLICK_Z) { SingleClickDetect = 0x01; } } Counter = 0x00; } }} and this is the vcp_DataTx function used to send data to USB port :static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len){ uint32_t i=0; for( i = 0; i < Len; i++ ) { APP_Rx_Buffer[APP_Rx_ptr_in] = (uint8_t) Buf[i]; APP_Rx_ptr_in++; if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) { APP_Rx_ptr_in = 0; } } return USBD_OK;}this function is called into this one : void DISCOVERY_EXTI_IRQHandler(void){ VCP_DataTx (Buffer[0], 1);}thanks in advance .