// == Program Code int main(int argc, char* argv[]) { // Initialisations programState = PROG_STATE_INIT; init_LCD(); init_ports(); init_EXTI(); init_NVIC(); init_ADC(); init_TIM14(); display(DISP_WELCOME, 0); programState = PROG_STATE_WAIT_FOR_SW0; // Infinite loop while (1) { __asm("nop"); } }
//==================================================================== // MAIN FUNCTION //==================================================================== void main (void){ init_LCD(); init_GPIO(); //Get operating CLK freq RCC_ClocksTypeDef CLK; RCC_GetClocksFreq(&CLK); sysclock= (CLK.SYSCLK_Frequency)/((float)(pow(10,6))); //Sys clocks in MHz sprintf(lcdstring,"CLK %d MHz",sysclock); lcd_putstring(lcdstring); lcd_command(LINE_TWO); lcd_putstring("Servo Step Test, SW0"); //Init procedure waits for SW0 while(GPIO_ReadInputData(GPIOA)&GPIO_IDR_0){} lcd_command(CLEAR); init_ADC(); init_EXTI(); init_USART1(); init_TIM2(); init_TIM3(); init_TIM14(); init_TIM17(); for(;;){ while(TIM3OC2<=3800){ TIM3OC2++; TIM_SetCompare2(TIM3,TIM3OC2); for(int x=0;x<=255;x++){ for(int y=0;y<=255;y++){} } } lcd_command(CURSOR_HOME); sprintf(lcdstring,"ADC:%d ",(int) ADCval); lcd_putstring(lcdstring); lcd_command(LINE_TWO); sprintf(lcdstring,"TIM:%d ",(int) TIM2->CCR3);//TIMcmp); //TIM_SetCompare2(TIM3,(int)(64000*((0.9+1.1*ADCval/2047.0)/20.0))); lcd_putstring(lcdstring); } } // End of main