타이머 카운터 파형발생 모드 0x8989C402 ==>>WAVESELL= 10(C) LED점점 밝아 지기
/* 타이머 카운터 파형발생 모드 0x8989C402 ==>>WAVESELL= 10(C) LED점점 밝아 지기 */
#include "AT91SAM7S256.h"
#include "lib_AT91SAM7S256.h"
#include "OK7S256ads.h"
#define DBGU_SR (*(volatile unsigned int *) 0xFFFFF214)
#define DBGU_RHR (*(volatile unsigned int *) 0xFFFFF218)
#define DBGU_THR (*(volatile unsigned int *) 0xFFFFF21C)
#define DBGU_MR (*(volatile unsigned int *) 0xFFFFF204)
#define DBGU_BRGR (*(volatile unsigned int *) 0xFFFFF220)
#define DBGU_CR (*(volatile unsigned int *) 0xFFFFF200)
#define PIO_ASR (*(volatile unsigned int *) 0xFFFFF470)
#define PIO_BSR (*(volatile unsigned int *) 0xFFFFF474)
#define PIO_PDR (*(volatile unsigned int *) 0xFFFFF404)
#define PIO_SODR (*(volatile unsigned int *) 0xFFFFF430)
#define PIO_CODR (*(volatile unsigned int *) 0xFFFFF434)
#define PIO_OER (*(volatile unsigned int *) 0xFFFFF410)
#define PIT_MR (*(volatile unsigned int *) 0xFFFFFD30)
#define AIC_SVR ((volatile unsigned int *) 0xFFFFF080)
#define AIC_SMR ((volatile unsigned int *) 0xFFFFF000)
#define AIC_IDCR (*(volatile unsigned int *) 0xFFFFF124)
#define AIC_ICCR (*(volatile unsigned int *) 0xFFFFF128)
#define AIC_IECR (*(volatile unsigned int *) 0xFFFFF120)
#define PMC_PCER (*(volatile unsigned int *) 0xFFFFFC10)
#define PIT_PIVR (*(volatile unsigned int *) 0xFFFFFD38)
void Delayms(unsigned int ms) //딜레이 함수..
{
volatile unsigned int count, countmax = (48000000 / 10000) * ms;
for(count = 0; count < countmax; count++);
}
int main(void)
{
unsigned int TC0_RA =500; // initial register value
//unsigned int TC0_RB = 1000;
unsigned int TC0_RC =500;// 도착점
PIO_OER = 0x00000FFF;
//PIO_CODR = 0x0000FFFF;
PMC_PCER =(unsigned int)1 << (unsigned int)2;
AT91F_TC0_CfgPMC(); // enable clock of TC0
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, 0, AT91C_PA1_TIOB0 | AT91C_PA0_TIOA0);
// TIOA0,TIOB0 output(Peripheral B)
*AT91C_TC0_CMR = 0x8989C402; // TC0 Channel Control Register WAVESELL=10
*AT91C_TC0_CCR = 0x0005; // TC0 clock enable and start
*AT91C_TC0_RA = TC0_RA; // set TC0 register
//*AT91C_TC0_RB = TC0_RB;
*AT91C_TC0_RC = TC0_RC; //TC0_RC고정점
;
while(1)
{
TC0_RA-=100; //TC0_RC~TC0_RA 차이값이클수록 밝아진다.
if(TC0_RA==0) // 차이가 가장 많을때
TC0_RA=500; // 리셋= 불이꺼진다
Delayms(500);
*AT91C_TC0_RA =TC0_RA;
}
}