📄 dualwave.c
字号:
#ifndef _REFERENCE
//*-----------------------------------------------------------------------------
//* 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 : Dualwave.c
//* Object : AT91 - Timer Counter - Dual waveform generation
//* Translator : ARM Software Development Toolkit V2.11a
//*
//* Imported resources : None
//* Exported resources : MainApplication
//*
//* 1.0 30/09/98 JLV : Creation
//* 2.0 21/10/98 JCZ : Clean up
//*-----------------------------------------------------------------------------
/*
Configure the channel 0 of the Timer Counter (TC) of the AT91
to aim dual waveform generation :
- clock = MCKI / 1024
- Register A = 0x4000
toggle TIOA0 when reached
- Register B = 0x6000
toggle TIOB0 when reached
- Register C = 0x8000
toggle TIOA0 and TIOB0 when reached
generate trigger to restart the timer
--------------------------------------------------------------------------------
________ ________ ______
TIOA0 __| |________| |________| red LED / output
____________ ____________ ______
TIOB0 __| |____| |____| green LED / output
--------------------------------------------------------------------------------
*/
/*----- Called Macro instructions definition -----*/
/* None */
/*----- Files to be included Definition -----*/
/* None */
/*----- Types and Constants Definition -----*/
#define AT91_REG(x) (*(volatile unsigned long *)(x))
/*----- Imported Resources Definition -----*/
/* None */
/*---- Internal Resources Definition -----*/
/* None */
/*---- External Resources Definition -----*/
#define _REFERENCE(x) x
#define CORPS
#endif
//*-----------------------------------------------------------------------------
//* Function Name : MainApplication
//* Object : AT91 - Timer Counter - Dual waveform generation
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : None
//*-----------------------------------------------------------------------------
_REFERENCE (int MainApplication( void ))
#ifdef CORPS
//* Begin
{
// Clear PIO output corresponding to TIOA0, TIOB0 and TIOA1
AT91_REG(0xFFFF0000) = 0x00000016;
AT91_REG(0xFFFF0010) = 0x00000016;
AT91_REG(0xFFFF0034) = 0x00000016;
// Define TIOA0 and TIOB as peripheral
AT91_REG(0xFFFF0004) = 0x0006;
// Initialize the mode of the timer 0
AT91_REG(0xFFFE0004) =
(1 << 30) | // BSWTRG : software trigger set TIOB
(3 << 26) | // BCPC : Register C compare toggle TIOB
(3 << 24) | // BCPA : Register B compare toggle TIOB
(1 << 22) | // ASWTRG : software trigger set TIOA
(3 << 18) | // ACPC : Register C compare toggle TIOA
(3 << 16) | // ACPA : Register A compare toggle TIOA
(1 << 15) | // WAVE : Waveform mode
(1 << 14) | // CPCTRG : Register C compare trigger enable
(1 << 10) | // EEVT : XC0 as external event (TIOB = output)
(4 << 0) ; // TCCLKS : MCKI / 1024
// Initialize the RA Register value
AT91_REG(0xFFFE0014) = 0x4000;
// Initialize the RB Register value
AT91_REG(0xFFFE0018) = 0x6000;
// Initialize the RC Register value
AT91_REG(0xFFFE001C) = 0x8000;
// Enable the clock of the timer
AT91_REG(0xFFFE0000) = 0x0001;
// Trig the timer
AT91_REG(0xFFFE0000) = 0x0004;
// Define IRQ0 and FIQ as PIO
AT91_REG(0xFFFF0000) = 0x00001200;
//* End
return(0);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -