dbuezas / arduino-web-timers Goto Github PK
View Code? Open in Web Editor NEWApplication to configure and visualise timers. Support for Atmel atmega328p (e.g Arduino Uno, Nano, Pro-mini) and Logic Green lgt8f328p
Application to configure and visualise timers. Support for Atmel atmega328p (e.g Arduino Uno, Nano, Pro-mini) and Logic Green lgt8f328p
Let me start by saying ...Wow, wow and wow about the elegance of this tool. I think this will help a lot of people, also as a learning tool to grasp what timers actually do.
You asked for some feedback, and the only thing I found for now is that I can use Chrome or Opera as a browser to have the slider working. My Firefox browser won't let me use the slider for setting the OCRxA/B value(s).
This on a Windows10 PC.
I used this configuration.
)
/**
* URL: https://dbuezas.github.io/arduino-web-timers/#mcu=ATMEGA328P&timer=2&interruptA=on&OCR2A=50&interruptB=on&OCR2B=150&InterruptOnTimerOverflow=on&timerMode=Normal&clockPrescalerOrSource=128&FCPU_UI=8Mhz
* Mode : Normal
* Period : 2.048 ms
* Frequency: 488.28125 Hz
* Outputs : none
*/
void setup(){
noInterrupts();
TCCR2B =
1 << CS22;
TIMSK2 =
1 << OCIE2B |
1 << OCIE2A |
1 << TOIE2;
OCR2A = 50;
OCR2B = 150;
interrupts();
}
Somehow on my controller, TCCR2A was set to 1 but it should be 0.
I added TCCR2A = 0;
to the code and it works fine now.
Maybe add TCCR2A = 0;
in normal mode?
After you (@dbuezas) mentioned your Arduino Web Timers App, I tested it with Firefox. The result is here:
Timer 1:
I'm not tested, but in my opinion the correct program code would be:
PMX0 =
1 << WCE;
PMX0 =
1 << C1BF4;
Like setting of the clock prescaler register WCE meaning: update enable then update.
PMX0/1update: Must write logic one to WCE. In the following 6 system clocks PMX0/1 update will be finished by writing the register.
Timer 2:
In my opinion the correct program code would be:
PMX0 =
1 << WCE;
PMX1 =
1 << C2BF7;
Timer 0, no port switching code:
This warning is seen in the console:
useHash.ts:11 Throttling navigation to prevent the browser from hanging. See https://crbug.com/1038223. Command line switch --disable-ipc-flooding-protection can be used to bypass the protection
Clock/prescaler/top
always with lgt8f328p with 1.0.6 and arduino ide 1.8.15
I have try the timer 0 on normal mode with toggle ..no toggle but never have an output ??? i have block the normal loop to avoid arduino core to use timer0 because i was thinking this block the direct use of timer0 but same things.
This work with timer3..
void setup(){
//timer0 test
TCCR0A =
1 << COM0A1 |
1 << COM0B1;
TCCR0B =
1 << CS00;
OCR0A = 128;
OCR0B = 102;
//or others settings
//timer0 test
// TCCR0A =
// 1 << COM0A1 |
// 1 << COM0B1;
// TCCR0B =
// 1 << OC0AS |
// 1 << CS00;
// PMX0 =
// 1 << WCE |
// 1 << C0BF3;
// OCR0A = 51;
// OCR0B = 102;
//timer0 test
// TCCR0A =
// 1 << COM0A1 |
// 1 << COM0B1 |
// 1 << WGM01;
// TCCR0B =
// 1 << OC0AS |
// 1 << CS00;
// PMX0 =
// 1 << WCE |
// 1 << C0BF3;
// OCR0A = 51;
// OCR0B = 20;
//timers3 test work
//TCCR1A =
// 1 << COM1A0 |
// 1 << COM1B0;
// TCCR1B =
// 1 << CS10;
// OCR1A = 13107;
// OCR1B = 26214;
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
interrupts();
}
int main( void )
{
setup();
// Your code goes here
while (true) {};
}
void loop() {
// put your main code here, to run repeatedly:
}
It is a bit hacky and not performant.
Idea:
Hi again . with timer 0 any output and build failed on all mode
if i set the dead time with lgt328
Hi,
many thanks for your very helpful work!
It's also a very good tool to train somebody.
Within arduiono-web-timers scripts, the definition of the Clock Control Status Register is 'TCKSCR'.
Within your lgt8fx arduino board package it is 'TCKCSR'.
I agree, the definition in the data sheet is confusing ;)
Gruß
Jörg
These two are generating the same code:
https://dbuezas.github.io/arduino-web-timers/#mcu=LGT8F328P&timer=3&topValue=0xFFFF&interruptA=on
https://dbuezas.github.io/arduino-web-timers/#mcu=LGT8F328P&timer=3&topValue=OCR3A&interruptA=on
This seems to be because the first viable option for timer mode is not propagated to the code unless explicitly selected.
D1, B2, etc are not defined in standard atmel arduino core.
Pins B are mapped to D8-13 in lgt
Hello! Thanks for your software...
In Normal Mode (ATmEga328P), when select TOGGLE on OCA/B the code are
TCCR2A =
1 << COM2A1 |
1 << COM2B1;
TCCR2B =
1 << CS22 |
1 << CS21 |
1 << CS20;
But must be 1 << COM2A0 |
1 << COM2B0;
Best regards...
See here dbuezas/lgt8fx#245 (comment)
This will very good to add an input for set the frequency source of timer that the graph use to displays the event and to have the timing on the graphic scale numbers to be able to see the timming event like
the "real world" case of the board... 16Mhz board..8mhz... or for some special case with some quartz with special frequencies very very less usual but sometime very interesting to have the microcontrollers to "BPM" exactly to this special frequencies...
So if done many time will be win with web timer to have the goods settings to have the timer good real life timing found...
When I played with arduino-web-timers, I noticed the Timer 0 dead time can only be adjusted to maximum 15. I looked out why.
So I noticed the generated code has a bug.
TCCR0A =
1 << COM0A1 |
1 << COM0B1 |
1 << WGM00;
TCCR0B =
1 << DTEN0 |
1 << CS00;
DDRD =
1 << DDD5 |
1 << DDD6;
OCR0A = 59;
OCR0B = 110;
DTR0L = 11; <-- There are no independent DTR0L and DRT0H registers
DTR0H = 9;
DTR0 = (9 << 4 | 11) is (9 * 16 + 11) is (155)
I think the correct setting of the Timer 0 DTR0 register for the example above is:
DTR0 = 155;
Hello many thanks for this wonderfull timer configurator.
I do some try.
The pinout is quiet difficult to find the real pin .. perhaps add arduino pin number or physical of lgt qfp48 and 32 ???
I have want to put Dead time on timer 3 with pcpwm mode but at build time
this report not valid in this scope...
I have try same setting for timer 3 with FPWM mode this build ok.
My device is wavgat avga328p clone minipro.
Have a nice day.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.