Comments (4)
Dear Mohdrais,
The TimerA is used by the Arduino core for millis() and micros().
I'm not sure if you can use TimerA features without breaking these functions.
What would you like to use TimerA for that cannot be done with TimerB0, 1 and 2 ?
WR,
Kees
from arduino-nano-every-timer-controller-b.
Mohdrais,
I gave some suggestions on:
https://forum.arduino.cc/index.php?topic=626736.new
WR,
Kees
from arduino-nano-every-timer-controller-b.
Dear Mohdrais,
I added the method:
void setPwmMode(byte period, byte compare)
You can use this for TCB0 to enable PWM on pin 6 and for TCB1 to enable PWM on pin 3.
The period argument (1-255) determines together with the clock the frequency:
// 16MHz clock: slowest frequency @ 255 = 62 kHz.
// 8MHz clock: slowest frequency @ 255 = 31 kHz.
// 256kHz clock: slowest frequency @ 255 = 1 kHz.
If you select a lower period than 255, the frequency will be faster.
The compare argument should be lower than the period argument and determines the duty cycle. If the compare argument is 2x smaller than the period, the duty cycle is 50 %.
EveryTimerB TimerB0;
TimerB0.initialize(&TCB0);
TimerB0.setClockSource(TCB_CLKSEL_CLKTCA_gc); // 250 kHz clock
pinMode(6,OUTPUT);
TimerB0.setPwmMode(127,64); // 2 kHz frequency, 50% duty cycle
I hope this helps.
Kees
from arduino-nano-every-timer-controller-b.
from arduino-nano-every-timer-controller-b.
Related Issues (9)
- variable frequency PWM HOT 4
- Invalid library error when trying to add HOT 1
- invalid conversion from 'int' to 'TCB_CLKSEL_t HOT 5
- disablePwm function on TimerOne not implemented in EveryTimerB HOT 2
- Is it possible to make a profile timer with this library. HOT 1
- Change Frequency HOT 1
- More than one timer HOT 1
- File name case incorrect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-nano-every-timer-controller-b.