This is a custom function to convert a number to the ASCII representation

Code C - [expand]

1
2
3
4
5
6
7
8

/******************************************************************************* Function name: ULongToStr**** Descriptions: converts an unsigned long to ASCII characters and stores the result to a char array** ** parameters: unsigned long value : number to be converted** char *str : pointer to the first char of the array** char leading_zero

The atmega has a few different PWM modes, the frequency and duty ratio depend on the mode and values used, this is a description of the way to calculate them.

In fast PWM top=ICR1, the output PWM frequency=timer clock/(ICR1+1) and the duty=OCR1A(B)/ICR1
In fast PWM top=0h00ff, the output PWM frequency=timer clock/256 and the duty=OCR1A(B)/256
In fast PWM top=0h01ff, the output PWM frequency=timer clock/512 and the duty=OCR1A(B)/512
In fast PWM top=0h03ff, the