1. The ATmega328P MCU of the UNO Board has hardware to genertae high frequency PWM signal using TCNT1 (Timer/Counter 1). The proposed 80 kHz signal will appear at DPin-9 of the UNO Board as per Fig-1. For test purpose, the duty cycle (ON-period) of the PWM signal ca be varied by rotating the Pot at 1-sec interval and the result will can be viewed as the increasing/decreasing brightness of LED1.


Figure-1:
2. Upload the following skecth in UNO (untested).
void setup() //generation of 80 kHz PWM signal using TCNT1
{
Serial.begin(9600);
pinMode(9, OUTPUT); //DPin-9 will deliver PWM signal for Ch-A
TCCR1A = 0b11100010; //COM1A1 COM1A0 COM1B1 COM1B0 b4 b3 b2 WGM11 WGM10; Mode-10 PWM; inverting
TCCR1B = 0b00010001; //b7 b6 b5 WGM13 WGM12 CS12 CS11 CS10; Mode-10 PWM; division factor = 1; clkTC1 = clkSYS/1
ICR1 = 100; //foc1A = 80 kHz;
//fDSPWM = (clkSYS/N)/(2*ICR1) = clkSYS/(2*N*ICR1) = clkSYS/(2*N*TOP)
// 80*1000 = 16000000/(2*1*ICR1); ICR1 = 1600/16 = 100
TCNT1 = 0x0000; //initial count
}
void loop() //changing the duty cycle (ON-period) manually
{
if (bitRead(TIFR1, OCF1A) == HIGH)//if TCNT1 matches with OCR1A;change duty cycle
{
bitSet(TIFR1, OCF1A); //clear flag
OCR1A = map(analogRead(A0), 0, 1023, 0, 95);//95 < ICR1 = 100 new value for new duty cycle
Serial.println(OCR1A, DEC); //shows the value written into OCR1 register
delay(1000); //test interval
}
}
3. Slowly rotate Pot. Check that te brightness of LED1 changes. Check in the oscilloscope that the duty cycle of the PWM signal changes and the frequency is exactly 80 kHz.
4. Observe the OCR1 value in the Serial Monitor as the Pot is rotated. Check that the brightness decreases as the OCR1 value increases. Also, check that the new on-period is updated in 1-sec period. It agrees with Fig-1; where, the on-period reduces as the OCR1 value increases. Refer to Post-6 @MarkT and note that the value of OCR1 register (controls the duty cycle) is kept below the value of ICR1 register (controls the frequency at 80 kHz with value 100).