lib_pwm.h

来自「IAR编译环境下的AT91SAM7S64芯片的PWM输出演示」· C头文件 代码 · 共 59 行

H
59
字号
//*----------------------------------------------------------------------------
//*      ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : lib_pwm.h
//* Object
//* 1.1 04/Apr/05 JPP   : Creation

//*----------------------------------------------------------------------------
#ifndef lib_pwm_h
#define lib_pwm_h

#define PWM_INTERRUPT_LEVEL           4
#define SOFT_INTERRUPT_LEVEL          0


/* Select the wanted frequency in hertz.
This choice has to be in accordance with the selected clock source */
#define SAMPLE_FREQUENCY    8000  // In Hertz
#define OVER_SAMPLING       64000  // In Hertz
#define SAMPLE_SIZE	    256
#define OVER_SAMPLING_RATE  (OVER_SAMPLING/SAMPLE_FREQUENCY)
#define DIVIDER 	    ((MCK/(OVER_SAMPLING*SAMPLE_SIZE))+1)


/*    PWM Clock source Domain */
#define         MCKtoPWM      0
#define         MCK_2toPWM    1
#define         MCK_4toPWM    2
#define         MCK_8toPWM    3
#define         MCK_16toPWM   4
#define         MCK_32toPWM   5
#define         MCK_64toPWM   6
#define         MCK_128toPWM  7
#define         MCK_256toPWM  8
#define         MCK_512toPWM  9
#define         MCK_1024toPWM 10
#define         CLHAtoPWM     11
#define         CLHBtoPWM     12

#define         CALG_OFF       0
#define         CALG_ON       1<<8  // The period is center aligned (OFF, left aligned)

#define         CPOL_OFF      0<<0  // The ouput waveform starts at a high level (OFF, low level)
#define         CPOL_ON       1<<9  // The ouput waveform starts at a high level (OFF, low level)

#define         CPD_ON        1<<10 // The period will be modified at the next period start event
#define         CPD_OFF       0<<10


extern void AT91F_PWM_Open(void);

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?