프로젝트 자료실
작성자 임베디드코리아
작성일16-08-04 12:07
조회3,311회
댓글0건
#include "lm3s9b92.h"
#define PWM0_0_CTL_R (*((volatile unsigned long *)0x40028000))
#define PWM0_0_GENA_R (*((volatile unsigned long *)0x40028060))
#define PWM0_0_LOAD_R (*((volatile unsigned long *)0x40028050))
#define PWM0_0_CMPA_R (*((volatile unsigned long *)0x40028058))
#define PWM0_ENABLE_R (*((volatile unsigned long *)0x40028008))
int main()
{
unsigned long ulValue;
unsigned long ulLoop;
ulValue = SYSCTL_RCGC0_R & ~(0x00100000);
SYSCTL_RCGC0_R = ulValue | 0x00100000;
__asm(" nop ");
__asm(" nop ");
__asm(" nop ");
ulValue = SYSCTL_RCGC2_R & ~(0x20);
SYSCTL_RCGC2_R = ulValue | 0x20;
__asm(" nop ");
__asm(" nop ");
__asm(" nop ");
ulValue = GPIO_PORTF_AFSEL_R & ~(0x01);
GPIO_PORTF_AFSEL_R = ulValue | 0x01;
ulValue = GPIO_PORTF_PCTL_R & ~(0x0F);
GPIO_PORTF_PCTL_R = ulValue | 0x03;
ulValue = GPIO_PORTF_DEN_R & ~(0x01);
GPIO_PORTF_DEN_R = ulValue | 0x01;
ulValue = SYSCTL_RCC_R & ~(0x001E0000);
SYSCTL_RCC_R = ulValue | 0x00000000;
ulValue = PWM0_0_CTL_R & ~(0x7FFFF);
PWM0_0_CTL_R = ulValue | 0;
ulValue = PWM0_0_GENA_R & ~(0x008C);
PWM0_0_GENA_R = ulValue | 0x008C;
ulValue = PWM0_0_LOAD_R & ~(0xFFFF);
PWM0_0_LOAD_R = ulValue | 0x0FFF;
ulValue = PWM0_0_CMPA_R & ~(0xFFFF);
PWM0_0_CMPA_R = ulValue | 0x07FF;
ulValue = PWM0_ENABLE_R & ~(0x01);
PWM0_ENABLE_R = ulValue | 0x01;
while(1)
{
ulValue = PWM0_0_CTL_R & ~(0x01);
PWM0_0_CTL_R = ulValue | 0x01;
for(ulLoop = 0; ulLoop < 1000000; ulLoop++);
ulValue = PWM0_0_CTL_R & ~(0x01);
PWM0_0_CTL_R = ulValue | 0x00;
for(ulLoop = 0; ulLoop < 1000000; ulLoop++);
} //end while
//return 0;
} //end main