![]() ![]() The output compare pin is OC3A, and is multiplexed to C6, while the input capture pin is IPC3, which is multiplexed to C7. ![]() Timer 3 is a 16-bit free-running timer with one output compare unit, and a single input capture unit. ![]() So, make is as simple and stupid as possible and concentrate on the pseudo random number generator. MEAM.Design - ATmega32 Programming - Timers/Counters - Timer 3 Configuration Details. Time critical applications, like time measurements without a hardware timer, that should perform excellent, must be written in assembler. In all cases, the algorithm that you will use to generate the pseudo random numbers is much more important than the seed generation approach. Because only necessary code steps are executed, assembly programs are as fast as possible. This way, the human provided switch ON will provide random moment event. The Atmega controllers provide hardware counters. Simple delays can be produced using the timer/counter1 by writing the required delay values into the respective registers. This way you will get better randomization, because the RTC runs even if the whole devide is switched off. ATmega8 have 3 different timers, of which the simplest one is TIMER0, with an 8 bit (0-255) resolution. The Timer/Counter1 module in ATmega328P The 16-bit Timer/Counter unit allows accurate program execution timing (event management), wave generation, and signal timing measurement. If your device supports real time clock, use it. This way, you can use for example some of the timers, configured to the fastest possible frequency, or even a simple software counter incremented on every main program loop (of course if the program is fast enough). Several kilohertz is a acceptable frequency. The only requirement to it is to run much more faster then the human reaction time. The counter is not actually so important. In the computers, the human randomizes the moment of the program start. Ive been rehashing some existing libraries I found on some obscure forums to measure a frequency on digital pin 5, using the ATmega328P/ATmega2560 Timer/Counter modules and an interrupt based approach in order to be able to measure frequencies up to 4MHz (-ish). Without human interaction, it is not possible to get random number seed using timer or counter. In order to do it, you need a timer/counter that counts fast and continuously and human that actually performs as a random event generator. Interrupts and 16-bit Timer/Counter 1: Atmel AVR Timers and Interrupts. You can use it only as a source for the pseudo random algorithm seed number. I see, you know it, but to emphasize once again, you can't use any timer/counter value as random number generator. ![]()
0 Comments
Leave a Reply. |