Initial Releases v1.0.0
- Initial coding to support megaAVR boards, such as UNO WiFi Rev2, AVR_Nano_Every, etc., using
Arduino megaAVRorMegaCoreXcore - The hardware-based PWM channels using TimerB can generate very high frequencies.
Debug Terminal Output Samples
1. PWM_DynamicDutyCycle on MegaCoreX Nano Every
The following is the sample terminal output when running example PWM_DynamicDutyCycle on megaAVR Nano Every using MegaCoreX, to demonstrate the ability to provide high PWM frequencies and ability to change DutyCycle on-the-fly.
Starting PWM_DynamicDutyCycle on MegaCoreX Nano Every
megaAVR_PWM v1.0.0
[PWM] megaAVR_PWM: _dutycycle = 32767
[PWM] setPWM_Int: input dutycycle = 127
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 3200
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 50 , _actualFrequency = 5000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 24 , DC % = 50.00
=====================================================================================
Change PWM DutyCycle to 90.00
[PWM] setPWM: _dutycycle = 58981
[PWM] setPWM_Int: input dutycycle = 230
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 224 , DC % = 90.00
=====================================================================================
Actual data: pin = 3, PWM DC = 90.00, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
=====================================================================================
Change PWM DutyCycle to 10.00
[PWM] setPWM: _dutycycle = 6553
[PWM] setPWM_Int: input dutycycle = 25
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 24 , DC % = 10.00
=====================================================================================
Actual data: pin = 3, PWM DC = 10.00, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
=====================================================================================
Change PWM DutyCycle to 90.00
[PWM] setPWM: _dutycycle = 58981
[PWM] setPWM_Int: input dutycycle = 230
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 224 , DC % = 90.00
=====================================================================================
Actual data: pin = 3, PWM DC = 90.00, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
=====================================================================================
2. PWM_Multi on megaAVR Nano Every
The following is the sample terminal output when running example PWM_Multi on megaAVR Nano Every, to demonstrate the ability to provide high PWM frequencies on multiple PWM-capable pins.
Starting PWM_Multi on megaAVR Nano Every
megaAVR_PWM v1.0.0
=====================================================================================
Index Pin PWM_freq DutyCycle Actual Freq
=====================================================================================
0 3 1000.00 10.00 1000.0000
1 6 4000.00 50.00 4000.0000
=====================================================================================
Actual data: pin = 3, PWM DC = 10.00, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
=====================================================================================
=====================================================================================
Actual data: pin = 6, PWM DC = 50.00, PWMPeriod = 62.00, PWM Freq (Hz) = 4000.0000
=====================================================================================
3. PWM_DynamicFreq on megaAVR Nano Every
The following is the sample terminal output when running example PWM_DynamicFreq on megaAVR Nano Every, to demonstrate the ability to change dynamically PWM frequencies.
Starting PWM_DynamicFreq on megaAVR Nano Every
megaAVR_PWM v1.0.0
[PWM] megaAVR_PWM: _dutycycle = 32767
[PWM] setPWM_Int: input dutycycle = 127
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 124 , DC % = 50.00
=====================================================================================
Change PWM Freq to 4000.00
[PWM] setPWM: _dutycycle = 32767
[PWM] setPWM_Int: input dutycycle = 127
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 4000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 62 , _actualFrequency = 4000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 30 , DC % = 50.00
=====================================================================================
Actual data: pin = 3, PWM DC = 50.00, PWMPeriod = 62.00, PWM Freq (Hz) = 4000.0000
=====================================================================================
Change PWM Freq to 1000.00
[PWM] setPWM: _dutycycle = 32767
[PWM] setPWM_Int: input dutycycle = 127
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 124 , DC % = 50.00
=====================================================================================
Actual data: pin = 3, PWM DC = 50.00, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
=====================================================================================
4. PWM_Waveform on megaAVR Nano Every
The following is the sample terminal output when running example PWM_Waveform on megaAVR Nano Every, to demonstrate how to use the setPWM_manual() function in wafeform creation
Starting PWM_Waveform on megaAVR Nano Every
megaAVR_PWM v1.0.0
[PWM] megaAVR_PWM: _dutycycle = 0
[PWM] setPWM: _dutycycle = 0
[PWM] setPWM_Int: input dutycycle = 0
[PWM] setPWM_Int: _timer = 3
[PWM] setPeriod_TimerB: F_CPU = 16000000 , cycles = 16000
[PWM] setPeriod_TimerB: cycles < TIMERB_RESOLUTION * 64, using divider = 64
[PWM] setPeriod_TimerB: pwmPeriod = 250 , _actualFrequency = 1000.00
[PWM] setPWM_Int: TIMERB, _dutycycle = 0 , DC % = 0.40
============================================================================================
Actual data: pin = 3, PWM DutyCycle = 0.40, PWMPeriod = 250.00, PWM Freq (Hz) = 1000.0000
============================================================================================
[PWM] PWM enabled, DCValue = 0 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 15 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 31 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 46 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 62 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 78 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 93 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 109 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 125 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 140 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 156 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 171 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 187 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 203 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 218 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 234 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 250 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 234 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 218 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 203 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 187 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 171 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 156 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 140 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 125 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 109 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 93 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 78 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 62 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 46 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 31 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 15 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00
[PWM] PWM enabled, DCValue = 0 , pwmPeriod = 250 , _frequency = 1000.00 , _actualFrequency = 1000.00