📄 main.c
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
/* DZ60 initialization functions */
#include "DZ60_init.h"
/* I/O macros */
#define LED1 PTCD_PTCD5 /* User LEDs */
#define LED2 PTBD_PTBD3
#define PB1 PTBD_PTBD6 /* Push buttons */
#define PB2 PTBD_PTBD7
#define ON 0
#define OFF 1
void AD1_Init(void);
static unsigned char potentiometer_value;
void AD1_Init(void)
{
/* ADCSC2: ADACT=0,ADTRG=0,ACFE=0,ACFGT=0,??=0,??=0,??=0,??=0 */
(ADCSC2=0x00); /* Disable HW trigger and autocompare */
/* ADCCFG: ADLPC=0,ADIV1=1,ADIV0=1,ADLSMP=0,MODE1=0,MODE0=0,ADICLK1=1,ADICLK0=1 */
(ADCCFG=0x63); /* Set prescaler bits */
/* ADCSC1: COCO=0,AIEN=0,ADCO=0,ADCH4=1,ADCH3=1,ADCH2=1,ADCH1=1,ADCH0=1 */
(ADCSC1=0x1F); /* Disable the module */
}
void main(void)
{
MCG_Init(); /* Clock Generator initialization */
SOPT1_COPT = 0; /* Watchdog disabled */
GPIO_Init(); /* GPIO configuration */
APCTL2 = 0x10; //AD set
AD1_Init();
EnableInterrupts; /* Enable interrupts */
for(;;)
{
ADCSC1 = 0x0c ;
while (!(ADCSC1 & 0x80));
potentiometer_value = ADCRL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -