RTEMS: bsps/arm/atsam/contrib/libraries/libchip/source/tc.c File Reference

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Functions
tc.c File Reference
`#include "board.h"`
`#include <assert.h>`

## Functions
void | TC_Configure (Tc *pTc, uint32_t dwChannel, uint32_t dwMode)
| Configures a Timer Counter Channel.
void | TC_Start (Tc *pTc, uint32_t dwChannel)
| Reset and Start the TC Channel.
void | TC_Stop (Tc *pTc, uint32_t dwChannel)
| Stop TC Channel.
uint32_t | TC_FindMckDivisor (uint32_t dwFreq, uint32_t dwMCk, uint32_t *dwDiv, uint32_t *dwTcClks, uint32_t dwBoardMCK)
| Find best MCK divisor.

## Detailed Description

# Purpose

Interface for configuring and using Timer Counter (TC) peripherals.

# Usage

1. Optionally, use TC_FindMckDivisor() to let the program find the best TCCLKS field value automatically.
2. Configure a Timer Counter in the desired mode using TC_Configure().
3. Start or stop the timer clock using TC_Start() and TC_Stop().

Implementation of Timer Counter (TC).

## Function Documentation

## ◆ TC_Configure()

void TC_Configure | ( | Tc * | pTc,
|  | uint32_t | dwChannel,
|  | uint32_t | dwMode
| ) |  |

Configures a Timer Counter Channel.

Configures a Timer Counter to operate in the given mode. Timer is stopped after configuration and must be restarted with TC_Start(). All the interrupts of the timer are also disabled.

Parameters

  pTc | Pointer to a Tc instance.
  channel | Channel number.
  mode | Operating mode (TC_CMR value).

## ◆ TC_FindMckDivisor()

uint32_t TC_FindMckDivisor | ( | uint32_t | dwFreq,
|  | uint32_t | dwMCk,
|  | uint32_t * | dwDiv,
|  | uint32_t * | dwTcClks,
|  | uint32_t | dwBoardMCK
| ) |  |

Find best MCK divisor.

Finds the best MCK divisor given the timer frequency and MCK. The result is guaranteed to satisfy the following equation:

(MCK / (DIV * 65536)) <= freq <= (MCK / DIV)

with DIV being the highest possible value.

Parameters

  dwFreq | Desired timer frequency.
  dwMCk | Master clock frequency.
  dwDiv | Divisor value.
  dwTcClks | TCCLKS field value for divisor.
  dwBoardMCK | Board clock frequency.

Returns
  1 if a proper divisor has been found, otherwise 0.

## ◆ TC_Start()

void TC_Start | ( | Tc * | pTc,
|  | uint32_t | dwChannel
| ) |  |

Reset and Start the TC Channel.

Enables the timer clock and performs a software reset to start the counting.

Parameters

  pTc | Pointer to a Tc instance.
  dwChannel | Channel number.

## ◆ TC_Stop()

void TC_Stop | ( | Tc * | pTc,
|  | uint32_t | dwChannel
| ) |  |

Stop TC Channel.

Disables the timer clock, stopping the counting.

Parameters

  pTc | Pointer to a Tc instance.
  dwChannel | Channel number.