?? wave_burst.c
字號:
//*-----------------------------------------------------------------------------
//* 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 : wave_burst.c
//* Object : AT91 - Timer Counter - Burst waveform generation
//*
//* Exported resources : main
//*
//* 1.0 30/09/98 JLV : Creation
//* 2.0 24/07/00 PF : Clean up
//*-----------------------------------------------------------------------------
/*
Configure the channel 0 of the Timer Counter (TC) of the AT91
to aim Single waveform generation :
- clock = MCKI / 1024
- Register C = 0xA000
toggle TIOA1 when reached
generate trigger to restart the timer
Configure the channel 1 of the Timer Counter (TC) of the AT91
to aim single waveform generation by anding the clock with TIOA1 :
- clock = MCKI / 1024 ANDed with XC1 (TIOA0)
- Register C = 0x4000
toggle TIOA1 when reached
generate trigger to restart the timer
--------------------------------------------------------------------------------
___ ___ ___ ___ ___ ___ _
TIOA0 _| |___| |___| |___| |___| |___| |___| red LED / output
_ ___ _ _ ___ _ _ ___ _ _
TIOA1 _| |_| |_| |___| |_| |_| |___| |_| |_| |___| amber LED / output
--------------------------------------------------------------------------------
*/
#include "periph/stdc/std_c.h"
#include "eb40008.h"
#include "parts/r40008/reg_r40008.h"
#include "../Targets/ATEB40x_uartdrv.h"
#define BAUD_RATE 38400//115200
//*-----------------------------------------------------------------------------
//* Function Name : main
//* Object : AT91 - Timer Counter - Burst waveform generation
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : None
//*-----------------------------------------------------------------------------
int main ( void )
//* Begin
{
/* Enable and clear PIO pin corresponding to TIOA0, TIOB0 and TIOA1 */
PIO_PER = (1<<PIOTIOA0) | (1<<PIOTIOA1) | (1<<PIOTIOB0) ;
PIO_OER = (1<<PIOTIOA0) | (1<<PIOTIOA1) | (1<<PIOTIOB0) ;
PIO_CODR = (1<<PIOTIOA0) | (1<<PIOTIOA1) | (1<<PIOTIOB0) ;
TCB0_BMR = TC_TIOA0XC1 ; /* Define XC1 as TIOA0 for channel 0 */
PIO_PDR = (1<<PIOTIOA1) ; /* Define TIOA1 as peripheral */
TC1_CCR = TC_CLKDIS ; /* Disable the timer 1 */
/* Initialize the mode of the channel 1 */
TC1_CMR =
TC_ASWTRG_SET_OUTPUT | /* ASWTRG : software trigger set TIOA */
TC_ACPC_TOGGLE_OUTPUT | /* ACPC : Register C compare toggle TIOA */
TC_WAVE | /* WAVE : Waveform mode */
TC_CPCTRG | /* CPCTRG : Register C compare trigger enable */
TC_BURST_XC1 | /* BURST : XC1 is ANDed with the selected clock */
TC_CLKS_MCK1024 ; /* TCCLKS : MCKI / 1024 */
TC1_RC = 0x4000 ; /* Initialize the RC Register value */
TC1_CCR = TC_CLKEN ; /* Enable the clock of the timer */
TC1_CCR = TC_SWTRG ; /* Trig the timer */
PIO_PDR = (1<<PIOTIOA0) ; /* Define TIOA0 as peripheral */
TC0_CCR = TC_CLKDIS ; /* Disable the timer 0 */
/* Initialize the mode of the timer 0 */
TC0_CMR =
TC_ASWTRG_SET_OUTPUT | /* ASWTRG : software trigger set TIOA */
TC_ACPC_TOGGLE_OUTPUT | /* ACPC : Register C compare toggle TIOA */
TC_WAVE | /* WAVE : Waveform mode */
TC_CPCTRG | /* CPCTRG : Register C compare trigger enable */
TC_CLKS_MCK1024 ; /* TCCLKS : MCKI / 1024 */
TC0_RC = 0xA000 ; /* Initialize the RC Register value */
TC0_CCR = TC_CLKEN ; /* Enable the clock of the timer */
TC0_CCR = TC_SWTRG ; /* Trigg the timer */
return(0);
}//* End
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -