Embedded C Firmware Library : Arduino / Atmega328p
1
Register Level Embedded C Hardware Abstraction Library for AVR ATmega48A/PA/88A/PA/168A/PA/328/P or Arduino UNO/NANO/MINI
|
Library for 8-Bit Timer-0. More...
Go to the source code of this file.
Data Structures | |
struct | TIMER0_ConfigData |
Macros | |
TIMER0_OC0A_MODE | |
Options for Timer-0 Output Compare Pin A (OC0A) Mode | |
#define | TIMER0_OC0A_NO_OUTPUT (0<<COM0A1) | (0<<COM0A0) |
#define | TIMER0_OC0A_TOGGLE_ON_MATCH (1<<COM0A0) |
#define | TIMER0_OC0A_CLEAR_ON_MATCH (1<<COM0A1) |
#define | TIMER0_OC0A_SET_ON_MATCH (1<<COM0A1) | (1<<COM0A0) |
#define | TIMER0_OC0A_NON_INVERTING (1<<COM0A1) |
#define | TIMER0_OC0A_INVERTING (1<<COM0A1) | (1<<COM0A0) |
#define | TIMER0_OC0A_MASK (1<<COM0A1) | (1<<COM0A0) |
TIMER0_OC0B_MODE | |
Options for Timer-0 Output Compare Pin B (OC0B) Mode | |
#define | TIMER0_OC0B_NO_OUTPUT (0<<COM0B1) | (0<<COM0B0) |
#define | TIMER0_OC0B_TOGGLE_ON_MATCH (1<<COM0B0) |
#define | TIMER0_OC0B_CLEAR_ON_MATCH (1<<COM0B1) |
#define | TIMER0_OC0B_SET_ON_MATCH (1<<COM0B1) | (1<<COM0B0) |
#define | TIMER0_OC0B_NON_INVERTING (1<<COM0B1) |
#define | TIMER0_OC0B_INVERTING (1<<COM0B1) | (1<<COM0B0) |
#define | TIMER0_OC0B_MASK (1<<COM0B1) | (1<<COM0B0) |
TIMER0_MODE | |
Options for Timer-0 Operation / Waveform Generation Mode | |
#define | TIMER0_MODE_NORMAL (0<<WGM01) | (0<<WGM00) |
#define | TIMER0_MODE_PHASE_CORRECT_PWM (1<<WGM00) |
#define | TIMER0_MODE_CTC (1<<WGM01) |
#define | TIMER0_MODE_FAST_PWM (1<<WGM01) | (1<<WGM00) |
#define | TIMER0_MODE_MASK (1<<WGM01) | (1<<WGM00) |
TIMER0_PWM_TOP_COUNT | |
Options for the TOP Count Value in Timer-0 PWM Generation Mode | |
#define | TIMER0_PWM_TOP_0xFF (0<<WGM02) |
#define | TIMER0_PWM_TOP_OCRA (1<<WGM02) |
#define | TIMER0_PWM_TOP_MASK (1<<WGM02) |
TIMER0_PRESCALER | |
Options for Timer-0 Input Clock Prescaler | |
#define | TIMER0_PRESCALER_0 (0<<CS02) | (0<<CS01) | (0<<CS00) |
#define | TIMER0_PRESCALER_1 (1<<CS00) |
#define | TIMER0_PRESCALER_8 (1<<CS01) |
#define | TIMER0_PRESCALER_64 (1<<CS01) | (1<<CS00) |
#define | TIMER0_PRESCALER_256 (1<<CS02) |
#define | TIMER0_PRESCALER_1024 (1<<CS02) | (1<<CS00) |
#define | TIMER0_PRESCALER_MASK (1<<CS02) | (1<<CS01) | (1<<CS00) |
TIMER0_INTERRUPT | |
Options for the Interrupts for Timer-0 | |
#define | TIMER0_COMPARE_MATCH_A_INTERRUPT (1<<OCIE0A) |
#define | TIMER0_COMPARE_MATCH_B_INTERRUPT (1<<OCIE0B) |
#define | TIMER0_OVERFLOW_INTERRUPT (1<<TOIE0) |
Typedefs | |
TIMER0_CONFIGURATION_DATA | |
Structure used to Configure Timer-0 | |
typedef struct TIMER0_ConfigData | TIMER0_ConfigData |
Functions | |
ISR (TIMER0_OVF_vect) | |
Interrupt Service Routine for Timer-0 Overflow. More... | |
ISR (TIMER0_COMPA_vect) | |
Interrupt Service Routine for Timer-0 Compare Match A. More... | |
ISR (TIMER0_COMPB_vect) | |
Interrupt Service Routine for Timer-0 Compare Match B. More... | |
TIMER0_OVERFLOW_INTERRUPT_CONTROL | |
Public Functions to Control Timer-0 Overflow Interrupts | |
void | TIMER0_EnableOverflowInterrupt () |
Public Function to Enable Timer-0 Overflow Interrupt. More... | |
void | TIMER0_DisableOverflowInterrupt () |
Public Function to Disable Timer-0 Overflow Interrupt. More... | |
TIMER0_COMPARE_MATCH_A_INTERRUPT_CONTROL | |
Public Functions to Control Timer-0 Compare Match A Interrupts | |
void | TIMER0_EnableCompareMatchAInterrupt () |
Public Function to Enable Timer-0 Compare Match A Interrupt. More... | |
void | TIMER0_DisableCompareMatchAInterrupt () |
Public Function to Disable Timer-0 Compare Match A Interrupt. More... | |
TIMER0_COMPARE_MATCH_B_INTERRUPT_CONTROL | |
Public Functions to Control Timer-0 Compare Match B Interrupts | |
void | TIMER0_EnableCompareMatchBInterrupt () |
Public Function to Enable Timer-0 Compare Match B Interrupt. More... | |
void | TIMER0_DisableCompareMatchBInterrupt () |
Public Function to Disable Timer-0 Compare Match B Interrupt. More... | |
TIMER0_INTERRUPT_CONTROL | |
Public Functions to Control Timer-0 Compare Match B Interrupts | |
void | TIMER0_EnableAllInterrupt () |
Public Function to Enable Timer-0 All Interrupt. More... | |
void | TIMER0_DisableAllInterrupt () |
Public Function to Disable Timer-0 All Interrupt. More... | |
TIMER0_CONFIGURATION_AND_CONTROL | |
Public Functions to Control and Configure Timer-0 | |
void | TIMER0_Init (TIMER0_ConfigData Data) |
Public Function to Configure and Initialize Timer-0. More... | |
void | TIMER0_DeInit () |
Public Function to De-Initialize Timer-0. More... | |
TIMER0_OCR0x_WRITE | |
Public Functions to Set OCR0x Registers of Timer-0 | |
void | TIMER0_SetOCR0A (uint8_t Value) |
Public Function to Set OCR0A value. More... | |
void | TIMER0_SetOCR0B (uint8_t Value) |
Public Function to set OCR0B value. More... | |
TIMER0_SYSTEM_TICK_AND_TIME_READ | |
Public Functions to Read System Tick and Time updated by Timer-0 | |
uint32_t | TIMER0_GetSystemTick () |
Public Function to Read current System Tick Count. More... | |
uint64_t | TIMER0_GetSystemTimeUs () |
Public Function to Read current System Time in Microsecond. More... | |
uint32_t | TIMER0_GetSystemTimeMs () |
Public Function to Read current System Time in Millisecond. More... | |
TIMER0_TICK_AND_TIME_CONVERSION | |
Public Functions to Convert between Timer-0 System Tick and Microsecond | |
uint32_t | TIMER0_TickToUs (uint32_t Tick) |
Public Function to Convert Tick Count to Time in Microsecond. More... | |
uint16_t | TIMER0_UsToTick (uint16_t Time) |
Public Function to convert Time in Microsecond to Tick Count. More... | |
TIMER0_GENERATE_DELAY | |
Public Functions to Generate Delays using Timer-0 System Tick | |
void | TIMER0_DelayTick (uint16_t Tick) |
Public Function to Generate Blocking Delay in Tick Count. More... | |
void | TIMER0_DelayUs (uint16_t Time) |
Public Function to Generate Blocking Delay in Microsecond. More... | |
void | TIMER0_DelayMs (uint16_t Time) |
Public Function to Generate Blocking Delay in Millisecond. More... | |
Library for 8-Bit Timer-0.
Created: 01-05-2020 08:20:10 PM Author : Arnab Kumar Das Website: www.ArnabKumarDas.com Microcontroller Supported: ATmega48A/PA/88A/PA/168A/PA/328/P or Arduino UNO/NANO/MINI +-\/-+ PC6 1| |28 PC5 (A5/ADC5) RXD (D0) PD0 2| |27 PC4 (A4/ADC4) TXD (D1) PD1 3| |26 PC3 (A3/ADC3) (D2) PD2 4| |25 PC2 (A2/ADC2) PWM (D3) PD3 5| |24 PC1 (A1/ADC1) XCK (D4) PD4 6| |23 PC0 (A0/ADC0) VCC 7| |22 GND GND 8| |21 AREF PB6 9| |20 AVCC PB7 10| |19 PB5 (D13) OC0B (D5) PD5 11| |18 PB4 (D12) OC0A (D6) PD6 12| |17 PB3 (D11) PWM (D7) PD7 13| |16 PB2 (D10) PWM (D8) PB0 14| |15 PB1 (D9) PWM +----+
#define TIMER0_OC0A_NO_OUTPUT (0<<COM0A1) | (0<<COM0A0) |
Sets the Compare Output Mode of Pin OC0A to : Normal Port Operation, Pin Disconnected
#define TIMER0_OC0A_TOGGLE_ON_MATCH (1<<COM0A0) |
Sets the Compare Output Mode of Pin OC0A to : Toggle on Compare Match
#define TIMER0_OC0A_CLEAR_ON_MATCH (1<<COM0A1) |
Sets the Compare Output Mode of Pin OC0A to : Clear on Compare Match
#define TIMER0_OC0A_SET_ON_MATCH (1<<COM0A1) | (1<<COM0A0) |
Sets the Compare Output Mode of Pin OC0A to : Set on Compare Match
#define TIMER0_OC0A_NON_INVERTING (1<<COM0A1) |
Sets the Compare Output Mode of Pin OC0A to : Non-Inverting PWM Output
#define TIMER0_OC0A_INVERTING (1<<COM0A1) | (1<<COM0A0) |
Sets the Compare Output Mode of Pin OC0A to : Inverting PWM Output
#define TIMER0_OC0A_MASK (1<<COM0A1) | (1<<COM0A0) |
Mask for Timer-0 OC0A Compare Output Mode
#define TIMER0_OC0B_NO_OUTPUT (0<<COM0B1) | (0<<COM0B0) |
Sets the Compare Output Mode of Pin OC0B to : Normal Port Operation, Pin Disconnected
#define TIMER0_OC0B_TOGGLE_ON_MATCH (1<<COM0B0) |
Sets the Compare Output Mode of Pin OC0B to : Toggle on Compare Match
#define TIMER0_OC0B_CLEAR_ON_MATCH (1<<COM0B1) |
Sets the Compare Output Mode of Pin OC0B to : Clear on Compare Match
#define TIMER0_OC0B_SET_ON_MATCH (1<<COM0B1) | (1<<COM0B0) |
Sets the Compare Output Mode of Pin OC0B to : Set on Compare Match
#define TIMER0_OC0B_NON_INVERTING (1<<COM0B1) |
Sets the Compare Output Mode of Pin OC0B to : Non-Inverting PWM Output
#define TIMER0_OC0B_INVERTING (1<<COM0B1) | (1<<COM0B0) |
Sets the Compare Output Mode of Pin OC0B to : Inverting PWM Output
#define TIMER0_OC0B_MASK (1<<COM0B1) | (1<<COM0B0) |
Mask for Timer-0 OC0B Compare Output Mode
#define TIMER0_MODE_NORMAL (0<<WGM01) | (0<<WGM00) |
Sets the Timer/Counter Mode of Operation to : Normal TOP : 0xFF, Update of OCRx at : Immediate, TOV Flag Set on : MAX
#define TIMER0_MODE_PHASE_CORRECT_PWM (1<<WGM00) |
Sets the Timer/Counter Mode of Operation to : Phase Correct PWM, TOP : TIMER0_PWM_TOP_COUNT, Update of OCRx at : TOP, TOV Flag Set on : BOTTOM
#define TIMER0_MODE_CTC (1<<WGM01) |
Sets the Timer/Counter Mode of Operation to : Clear Timer on Compare Match (CTC) Mode, TOP : OCRA, Update of OCRx at : Immediate, TOV Flag Set on : MAX
#define TIMER0_MODE_FAST_PWM (1<<WGM01) | (1<<WGM00) |
Sets the Timer/Counter Mode of Operation to : Fast PWM Mode, TOP : TIMER0_PWM_TOP_COUNT, Update of OCRx at : BOTTOM, TOV Flag Set on : MAX/TOP
#define TIMER0_MODE_MASK (1<<WGM01) | (1<<WGM00) |
Mask for Timer/Counter Mode of Operation
#define TIMER0_PWM_TOP_0xFF (0<<WGM02) |
Sets the TOP to : 0xFF in any PWM Mode
#define TIMER0_PWM_TOP_OCRA (1<<WGM02) |
Sets the TOP to : OCRA in any PWM Mode
#define TIMER0_PWM_TOP_MASK (1<<WGM02) |
Mask for TOP value in any PWM Mode
#define TIMER0_PRESCALER_0 (0<<CS02) | (0<<CS01) | (0<<CS00) |
No Clock Source : Timer/Counter Stopped
#define TIMER0_PRESCALER_1 (1<<CS00) |
Sets the Timer-0 Clock Source to : F_CPU/1 : No Prescaling
#define TIMER0_PRESCALER_8 (1<<CS01) |
Sets the Timer-0 Clock Source to : F_CPU/8 : System Clock Divided by 8
#define TIMER0_PRESCALER_64 (1<<CS01) | (1<<CS00) |
Sets the Timer-0 Clock Source to : F_CPU/64 : System Clock Divided by 64
#define TIMER0_PRESCALER_256 (1<<CS02) |
Sets the Timer-0 Clock Source to : F_CPU/256 : System Clock Divided by 256
#define TIMER0_PRESCALER_1024 (1<<CS02) | (1<<CS00) |
Sets the Timer-0 Clock Source to : F_CPU/1024 : System Clock Divided by 1024
#define TIMER0_PRESCALER_MASK (1<<CS02) | (1<<CS01) | (1<<CS00) |
Mask for Timer-0 Prescaler
#define TIMER0_COMPARE_MATCH_A_INTERRUPT (1<<OCIE0A) |
Timer-0 Interrupt Control Bit : Compare Match A
#define TIMER0_COMPARE_MATCH_B_INTERRUPT (1<<OCIE0B) |
Timer-0 Interrupt Control Bit : Compare Match B
#define TIMER0_OVERFLOW_INTERRUPT (1<<TOIE0) |
Timer-0 Interrupt Control Bit : Timer Overflow
|
inline |
Public Function to Enable Timer-0 Overflow Interrupt.
|
inline |
Public Function to Disable Timer-0 Overflow Interrupt.
|
inline |
Public Function to Enable Timer-0 Compare Match A Interrupt.
|
inline |
Public Function to Disable Timer-0 Compare Match A Interrupt.
|
inline |
Public Function to Enable Timer-0 Compare Match B Interrupt.
|
inline |
Public Function to Disable Timer-0 Compare Match B Interrupt.
|
inline |
Public Function to Enable Timer-0 All Interrupt.
|
inline |
Public Function to Disable Timer-0 All Interrupt.
void TIMER0_Init | ( | TIMER0_ConfigData | Data | ) |
Public Function to Configure and Initialize Timer-0.
[in] | Data | : Structure Variable containing Timer-0 Configuration Data |
void TIMER0_DeInit | ( | ) |
Public Function to De-Initialize Timer-0.
|
inline |
Public Function to Set OCR0A value.
[in] | Value | : Variable to Store OCR0A Register value |
|
inline |
Public Function to set OCR0B value.
[in] | Value | : Variable to Store OCR0B Register value |
uint32_t TIMER0_GetSystemTick | ( | ) |
Public Function to Read current System Tick Count.
uint64_t TIMER0_GetSystemTimeUs | ( | ) |
Public Function to Read current System Time in Microsecond.
uint32_t TIMER0_GetSystemTimeMs | ( | ) |
Public Function to Read current System Time in Millisecond.
uint32_t TIMER0_TickToUs | ( | uint32_t | Tick | ) |
Public Function to Convert Tick Count to Time in Microsecond.
[in] | Tick | : Variable to Store Tick Count |
uint16_t TIMER0_UsToTick | ( | uint16_t | Time | ) |
Public Function to convert Time in Microsecond to Tick Count.
[in] | Time | : Variable to Store Time in Microsecond |
void TIMER0_DelayTick | ( | uint16_t | Tick | ) |
Public Function to Generate Blocking Delay in Tick Count.
[in] | Tick | : Variable to Store Tick Count |
void TIMER0_DelayUs | ( | uint16_t | Time | ) |
Public Function to Generate Blocking Delay in Microsecond.
[in] | Time | : Variable to Store Time in Microsecond |
void TIMER0_DelayMs | ( | uint16_t | Time | ) |
Public Function to Generate Blocking Delay in Millisecond.
[in] | Time | : Variable to Store Time in Millisecond |
ISR | ( | TIMER0_OVF_vect | ) |
Interrupt Service Routine for Timer-0 Overflow.
[in] | TIMER0_OVF_vect |
ISR | ( | TIMER0_COMPA_vect | ) |
Interrupt Service Routine for Timer-0 Compare Match A.
[in] | TIMER0_COMPA_vect |
ISR | ( | TIMER0_COMPB_vect | ) |
Interrupt Service Routine for Timer-0 Compare Match B.
[in] | TIMER0_COMPB_vect |