Opening the Header File from the C Source File in Atmel Studioĭocumentation can also be found online at The documentation contains more information and limitations of the two delay library functions. To open the delay.h file in Atmel Studio, right-click the header file name in the C source file and then click Goto Implementation on the menu that pops up. The header file delay.h contains documentation in the form of comments in the file. In Atmel Studio optimization level 1 is on by default. In order to use the _delay_ms() function and get it to delay for the specified time, firstly the frequency that the ATtiny2313 is running at must be specified by defining it at the top of the C source file as shown above.Ĭompiler optimization must be on for the function to generate the desired timing period. The same library has a microsecond delay function as well: _delay_us(). The function is called and passed the desired time delay in milliseconds. For circuit diagrams, see previous parts of this tutorial and modify to connect the LED to pin 14. In every PWM period counter must count 256 steps, so frequency of signal is 256 times lower than counter clock from prescaler. In not inverting mode duty cycle OCR2/256100 and it’s 50 if OCR2 is 0x80(middle between 0x00 0xFF). ![]() ![]() The software is shown below for an ATtiny2313 with an LED interfaced to pin 14 (PB2). From this all turns out that PWM duty cycle depends on OCR2 register. Can't see the video? View on YouTube → Software
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |