T
Tom2
Guest
používam analógový vstup PIC a mám vytvoriť pwm.When zmeniť amplitute vstupu Chcem zmeniť pracovný cyklus pwm.This nie happen.Is niekto why.I použitie Pic16F777 a PCM CCS kompilátor. Môj kód je: # include # zariadenia ADC = 16 # poistky XT, NOWDT, NOPROTECT # použitie oneskorenie (hodiny = 4000000) / / long duty_cycle, obdobie, void main () {long adc_result, setup_adc_ports (ALL_ANALOG) setup_adc (ADC_CLOCK_DIV_16) , setup_ccp1 (CCP_PWM) setup_timer_2 (T2_DIV_BY_1, 255, 1); while (1) {set_adc_channel (0); Delay_ms (1), adc_result read_adc = (); adc_result>> = 6; set_pwm1_duty (adc_result);}}