资源简介
单片机课程作业,屏幕显示,SPI通信,准确走时,使用AD采样
代码片段和文件信息
#include “grit.h“
#include “string.h“
unsigned int phase[12] ={312831303130313130313031};
unsigned int para4[5] = {-1 -1 -1 -1 -1};
unsigned int ha[5] = {0 0 0 0 0};
unsigned int ma[5] = {0 0 0 0 0};
unsigned int sa[5] = {0 0 0 0 0};
unsigned int j = 0;
//unsigned int k = 0;
void Temperture(void)
{
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
ADC12CTL0 = ADC12SHT0_8 + ADC12REFON + ADC12ON;
// Internal ref = 1.5V
ADC12CTL1 = ADC12SHP; // enable sample timer
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10; // ADC i/p ch A10 = temp sense i/p
ADC12IE = 0x001; // ADC_IFG upon conv result-ADCMEMO
//__delay_cycles(1000000); // Allow ~100us (at default UCS settings)
// for REF to settle
// ADC12CTL0 |= ADC12ENC;
// Temperature in Celsius. See the Device Descriptor Table section in the
// System Resets Interrupts and Operating Modes System Control Module
// chapter in the device user‘s guide for background information on the
// used formula.
ADC12CTL0 &= ~ADC12SC;
ADC12CTL0 |= ADC12SC; // Sampling and conversion start
temperatureDegC = (float)(((long)temp - CALADC12_15V_30C) * (85 - 30)) /
(CALADC12_15V_85C - CALADC12_15V_30C) + 30.0f;
// Temperature in Fahrenheit Tf = (9/5)*Tc + 32
temperatureDegF = temperatureDegC * 9.0f / 5.0f + 32.0f;
// temp=(int) temperatureDegC;//显示温度
temp=37;//显示温度
}
void XT2_Init(void){
TA0CCTL2 = OUTMOD_3; // CCR0 interrupt enabled
TA0CTL = TASSEL_2 + MC_1 + TACLR + ID_3;
TA0EX0 |= TAIDEX_7;//TimerA取XT2为信源4M,64分频后为62500HZ,所以TimerA每一秒进入一次中断
TA0CCR0 = 62500;
TA0CCR2 = 31250;
TA0CCTL0 = CCIE;
P1DIR |= BIT3;// P1.3 output
P1SEL |= BIT3;
P7SEL |= BIT2 + BIT3;
UCSCTL6 &= ~XT2OFF + XT2DRIVE_1;
UCSCTL3 |= SELREF_2;
UCSCTL4 |= SELA_2;
P5DIR |= BIT3;
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
SFRIFG1 &= ~OFIFG;
}
while (SFRIFG1&OFIFG);
UCSCTL6 &= ~XT2DRIVE0;
UCSCTL4 |= SELS_5 + SELM_5;
}
void Time_Given(void){
if(para1 == 1)
second++;
if(year % 4 == 0 && (year != 0 || century % 4 == 0))
phase[1] = 29;
else
phase[1] = 28;
if(day == 0)
day = 1;
if(second == 60){
second = 0;
minute++;
if(minute == 60){
minute = 0;
hour++;
if(hour == 24){
hour = 0;
day++;
if(day == phase[month - 1] + 1){
day = 1;
month++;
if(month == 13){
month = 1;
year++;
if(year == 100){
year = 0;
century++;
}
}
}
}
}
}
if(para2 < 9 && para6 != -1){
OLED_ShowNum(201century * 100 + year416);
OLED_ShowCHinese(55 1 7);
OLED_ShowNum(721mon
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 559 2018-07-15 21:57 0413\.ccsproject
文件 30445 2018-07-15 21:57 0413\.cproject
目录 0 2018-07-15 21:57 0413\.launches\
文件 4199 2018-05-01 12:31 0413\.launches\0413.launch
文件 834 2018-07-15 21:57 0413\.project
文件 17955 2018-04-29 21:50 0413\bmp.h
目录 0 2018-07-15 21:57 0413\Debug\
文件 91060 2018-05-01 14:19 0413\Debug\0413.map
文件 102220 2018-05-01 14:19 0413\Debug\0413.out
文件 331930 2018-05-01 14:19 0413\Debug\0413_li
文件 89 2018-07-15 21:57 0413\Debug\ccsObjs.opt
文件 40172 2018-05-01 14:19 0413\Debug\grit.obj
文件 1391 2018-05-01 14:19 0413\Debug\grit.pp
文件 17188 2018-05-01 14:09 0413\Debug\main.obj
文件 1011 2018-05-01 14:09 0413\Debug\main.pp
文件 4434 2018-07-15 21:57 0413\Debug\makefile
文件 264 2018-07-15 21:57 0413\Debug\ob
文件 36072 2018-05-01 12:17 0413\Debug\oled.obj
文件 1171 2018-05-01 12:17 0413\Debug\oled.pp
文件 2020 2018-07-15 21:57 0413\Debug\sources.mk
文件 2656 2018-07-15 21:57 0413\Debug\subdir_rules.mk
文件 665 2018-07-15 21:57 0413\Debug\subdir_vars.mk
文件 9521 2018-05-01 14:19 0413\grit.c
文件 1228 2018-05-01 12:06 0413\grit.h
文件 14295 2018-04-14 19:57 0413\lnk_msp430f6638.cmd
文件 1523 2018-05-01 14:09 0413\main.c
文件 6398 2018-04-29 22:23 0413\oled.c
文件 4041 2018-04-29 21:48 0413\oled.h
文件 14601 2018-04-21 14:30 0413\oledfont.h
目录 0 2018-07-15 21:57 0413\targetConfigs\
文件 822 2018-04-14 19:57 0413\targetConfigs\MSP430F6638.ccxm
............此处省略1个文件信息
- 上一篇:02129信息资源建设(四川)201910 真题
- 下一篇:VC操作word小常识
评论
共有 条评论