PWMGenPeriodSet(PWM_BASE,PWM_GEN_3,6000); //pwm period set
PWMPulseWidthSet(PWM_BASE,PWM_OUT_6,3000);
PWMOutputState(PWM_BASE, PWM_OUT_6_BIT,true ); // select the pwm and run
PWMGenEnable(PWM_BASE,PWM_GEN_0); //pwm out
}
晕死了!是不是我装的keil有问题啊,仿真的时候运行到PWMGenConfigure就报错!
*** error 65: access violation at 0x40028100 : no 'read' permission
*** error 65: access violation at 0x40028100 : no 'write' permission
#define pwm0 GPIO_PIN_0
void init(void );
int main()
{
unsigned int x=1000;
init();
while(1)
{
PWMPulseWidthSet(PWM_BASE,PWM_OUT_0,x);
SysCtlDelay(1000000);
x=x+100;
if(x>6000)
x=1000;
}
}
void init()
{
SysCtlLDOSet(SYSCTL_LDO_2_75V); //系统内核工作电压2.75V
SysCtlClockSet(SYSCTL_SYSDIV_8 | //系统8分频 系统频率=200/8=25MHz
SYSCTL_USE_PLL | //使用锁相环PLL
SYSCTL_OSC_MAIN | //使用主振荡器时钟
SYSCTL_XTAL_8MHZ); //系统晶振频率8MHz
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); //enable the GPIOH PH0->CCP6,
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM); //enable the PWM
SysCtlPWMClockSet(SYSCTL_PWMDIV_1 ); //set clk of pwm
GPIOPinTypePWM(GPIO_PORTH_BASE,pwm0); // select the PWM GPIOs
PWMGenConfigure(PWM_BASE,PWM_GEN_3 ,PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC ); //configure
PWMGenPeriodSet(PWM_BASE,PWM_GEN_3,6000); //pwm period set
PWMPulseWidthSet(PWM_BASE,PWM_OUT_6,3000);
PWMOutputState(PWM_BASE, PWM_OUT_6_BIT,true ); // select the pwm and run
PWMGenEnable(PWM_BASE,PWM_GEN_0); //pwm out
}
晕死了!是不是我装的keil有问题啊,仿真的时候运行到PWMGenConfigure就报错!
*** error 65: access violation at 0x40028100 : no 'read' permission
*** error 65: access violation at 0x40028100 : no 'write' permission
一周热门 更多>