📄 pllsetk.c
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: pllsetk.c
** Latest modified Date: 2007-09-16
** Latest Version: 1.1
** Descriptions: PLL设置实验程序
**
**--------------------------------------------------------------------------------------------------------
** Created by: Zhao shimin
** Created date: 2007-09-16
** Version: 1.0
** Descriptions: The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
/* 调用库函数的头文件 */
#include "hw_memmap.h"
#include "hw_types.h"
#include "ssi.h"
#include "gpio.h"
#include "sysctl.h"
#include "systick.h"
#define BEEP GPIO_PIN_7
void JTAGProtect(void);
/*********************************************************************************************************
** Function name: delay
**
** Descriptions: 延时函数,输入参数越大,延时时间越长
**
** input parameters: uld 延时时间值
** output parameters: NONE
**
** Returned value: NONE
**
** Created by: Zhao shimin
** Created Date: 2007/09/16
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void delay (unsigned long uld)
{
for(; uld; uld--);
}
/*********************************************************************************************************
** Function name: main
**
** Descriptions: PLL设置程序
**
** input parameters: NONE
** output parameters: NONE
**
** Returned value: NONE
**
** Created by: Zhao shimin
** Created Date: 2007/09/16
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main (void)
{
unsigned long i;
JTAGProtect();
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC |
SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ); /* 设置直接使用外部晶体 */
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); /* 给GPIOA提供时钟 */
/* 设定 GPIO PA6引脚为推挽2MA输出 */
GPIOPadConfigSet(GPIO_PORTA_BASE, BEEP, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
/* 设定 GPIO PA6 引脚为GPIO输出口 */
GPIODirModeSet(GPIO_PORTA_BASE, BEEP, GPIO_DIR_MODE_OUT);
for (i = 0; i < 10; i++) {
GPIOPinWrite(GPIO_PORTA_BASE,BEEP,~BEEP);
delay(200000);
GPIOPinWrite(GPIO_PORTA_BASE,BEEP,BEEP);
delay(200000);
}
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL | SYSCTL_XTAL_6MHZ); /* 设置使用PLL,10分频 */
for (i = 0; i < 10; i++) {
GPIOPinWrite(GPIO_PORTA_BASE,BEEP,~BEEP);
delay(200000);
GPIOPinWrite(GPIO_PORTA_BASE,BEEP,BEEP);
delay(200000);
}
while (1) {
;
}
}
/*********************************************************************************************************
** Function name: JTAGProtect
**
** Descriptions: 防止JTAG失效的程序
**
** input parameters: NONE
** output parameters: NONE
**
** Returned value: NONE
**
** Created by: Zhao shimin
** Created Date: 2007/09/16
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#define KEY3 GPIO_PIN_4
void JTAGProtect (void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); /* 给GPIOB提供时钟 */
/* 设定 GPIO PB4引脚为上拉2MA输入 */
GPIOPadConfigSet(GPIO_PORTB_BASE, KEY3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
/* 设定 GPIO PB4 引脚为GPIO输入口 */
GPIODirModeSet(GPIO_PORTB_BASE, KEY3, GPIO_DIR_MODE_IN);
while ((GPIOPinRead(GPIO_PORTB_BASE,KEY3) & KEY3)== 0) {
;
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -