/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
uint32_t num1,num2,num3,num4,ts;
char value;
int vt;
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
void TIM_SetTIM9Compare2(uint32_t compare)
{
TIM9->CCR2=compare;
}
void refresh()
{
uint16_t temp;
temp=data[num1+1]*256+data[num1];
TIM_SetTIM9Compare2(temp/64);
// temp=temp/8;
// TIM1->CCR1=temp;
// TIM1->CCR2=temp;
pwm_setvalue(temp/8,TIM_CHANNEL_1);
pwm_setvalue(temp/8,TIM_CHANNEL_2);
//
// temp=data3[num2+1]*256+data3[num2];
// //TIM_SetTIM9Compare2(temp/16);
// pwm_setvalue(temp/8,TIM_CHANNEL_3);
// pwm_setvalue(temp/8,TIM_CHANNEL_4);
num1++;
num2++;
if(num1>352400)
{num1=0;}
if(num2>2293500)
{num2=0;}
}
/*void refresh()
{
uint8_t temp;
temp=data[num]+128;
HAL_DAC_SetValue(&hdac,DAC_CHANNEL_1,DAC_ALIGN_12B_R,temp);
num++;
if(num>176280)
{num=0;}
}*/
/* USER CODE END 0 */
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim14);
HAL_DAC_Start(&hdac,DAC_CHANNEL_1);
HAL_TIM_PWM_Start(&htim9,TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_ALL);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/** System Clock Configuration
*/
void SystemClock_Config(void)
{
/* USER CODE BEGIN 4 */
/* USER CODE BEGIN 4 */
void pwm_setvalue(uint16_t value,uint32_t channel)
{
TIM_OC_InitTypeDef sConfigOC;
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = value;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_ENABLE;
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, channel);
HAL_TIM_PWM_Start(&htim1, channel);
}
/* USER CODE END 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler */
/* User can add his own implementation to report the HAL error return state */
while(1)
{
}
/* USER CODE END Error_Handler */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/