(I guess I really have 2 issues here: finer LED brightness control and doing PWM for a motor (since I also want to 'fade in/out' the motor RPM by changing the duty cycle). If this should be a separate thread, please let me know)..
For the motor application, I think I can configure the registers for the duty cycle (CCP1CON.4 & .5, CCPR1L) but I can't wrap my head around the frequency calculation (with 10-bit resolution at FOSC 32Mhz, I think I need PR2 = 255 with a timer prescale of 1 to get 31.25kHz judging from Table 24-5 in the PIC16F1825 datasheet). But what if I want to aim for 16-20kHz?




Bookmarks