프로젝트 자료실
작성자 임베디드코리아
작성일16-08-05 13:41
조회3,554회
댓글0건
#include "lm3s9b92.h"
int main()
{
unsigned long ulValue;
unsigned long ulLoop;
ulValue = SYSCTL_RCC_R & ~(0x00400800);
SYSCTL_RCC_R = ulValue | 0x00000800;
ulValue = SYSCTL_RCC_R & ~(0x000027F0);
SYSCTL_RCC_R = ulValue | 0x00000540;
ulValue = SYSCTL_RCC_R & ~(0x07C00000);
SYSCTL_RCC_R = ulValue | 0x01C00000;
for(ulLoop = 32768; ulLoop > 0; ulLoop--)
{
ulValue = SYSCTL_RIS_R & 0x0040;
if(ulValue){ break; }
}
ulValue = SYSCTL_RCC_R & ~(0x00000800);
SYSCTL_RCC_R = ulValue | 0x00000000;
ulValue = SYSCTL_RCGC2_R & ~(0x102);
SYSCTL_RCGC2_R = ulValue | 0x102;
__asm(" nop ");
__asm(" nop ");
__asm(" nop ");
ulValue = GPIO_PORTB_AFSEL_R & ~(0x01);
GPIO_PORTB_AFSEL_R = ulValue | 0x01;
ulValue = GPIO_PORTJ_AFSEL_R & ~(0x01);
GPIO_PORTJ_AFSEL_R = ulValue | 0x00;
ulValue = GPIO_PORTB_PCTL_R & ~(0x0F);
GPIO_PORTB_PCTL_R = ulValue | 0x01;
ulValue = GPIO_PORTB_DEN_R & ~(0x01);
GPIO_PORTB_DEN_R = ulValue | 0x01;
ulValue = GPIO_PORTJ_DEN_R & ~(0x01);
GPIO_PORTJ_DEN_R = ulValue | 0x01;
ulValue = GPIO_PORTJ_DIR_R & ~(0x01);
GPIO_PORTJ_DIR_R = ulValue | 0x01;
ulValue = GPIO_PORTJ_DATA_R & ~(0x01);
GPIO_PORTJ_DATA_R = ulValue | 0x00;
ulValue = SYSCTL_RCGC1_R & ~(0x10000);
SYSCTL_RCGC1_R = ulValue | 0x10000;
__asm(" nop ");
__asm(" nop ");
__asm(" nop ");
ulValue = TIMER0_CTL_R & ~(0x01);
TIMER0_CTL_R = ulValue | 0x00;
ulValue = TIMER0_CFG_R & ~(0x07);
TIMER0_CFG_R = ulValue | 0x00;
ulValue = TIMER0_TAMR_R & ~(0xFF);
TIMER0_TAMR_R = ulValue | 0x02;
ulValue = TIMER0_TAILR_R & ~(0xFFFFFFFF);
TIMER0_TAILR_R = ulValue | 0x2FAF080;
ulValue = TIMER0_CTL_R & ~(0x01);
TIMER0_CTL_R = ulValue | 0x01;
while(1)
{
ulValue = TIMER0_RIS_R & 0x01;
if(ulValue)
{
ulValue = GPIO_PORTJ_DATA_R &= ~(0x01);
GPIO_PORTJ_DATA_R = ulValue | 0x00;
for(ulLoop = 0; ulLoop < 350000; ulLoop++);
ulValue = GPIO_PORTJ_DATA_R & ~(0x01);
GPIO_PORTJ_DATA_R = ulValue | 0x01;
ulValue = TIMER0_ICR_R & ~(0x01);
TIMER0_ICR_R = ulValue | 0x01;
}
} //end while
} //end main