【文章內(nèi)容簡介】
X68 。 //邊沿對齊,高電平有效 TPM2C1V = 1535。 //占空比寄存器 for(。) { __RESET_WATCHDOG()。 /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ } 實(shí)驗(yàn)五 AD轉(zhuǎn)換 實(shí)驗(yàn)?zāi)康模?熟悉 ADC寄存器的設(shè)置和使用方法,實(shí)現(xiàn)對可調(diào)電阻電壓的的采樣。 實(shí)驗(yàn)結(jié)果 : 在 Data: 2變量查看窗口里面點(diǎn)右鍵,選擇 Mode, Peridical… 5 旋轉(zhuǎn)可調(diào)電阻,在調(diào)試環(huán)境下的變量查看窗口可以看到 AD 采樣值的變化。 主程序設(shè)計(jì) : include /* for EnableInterrupts macro */ include /* include peripheral declarations */ 6 void main(void) { int result。 EnableInterrupts。 /* enable interrupts */ /* include your code here */ ADC1CFG=ADC1CFG_ADLSMP_MASK| ADC1CFG_MODE1_MASK。 //Long sample time 10bit APCTL1=APCTL1_ADPC0_MASK。 //選通通道 0 ADC1SC1=0X20。 //啟動(dòng)轉(zhuǎn)換 for(。) { __RESET_WATCHDOG()。 /* feeds the dog */ if (ADC1SC1_COCO) //新的轉(zhuǎn)換是否完成 { result = ADC1R。 //讀取結(jié)果 (清除完成標(biāo)志 COCO) } } /* loop forever */ /* please make sure that you never leave main */ } 六 四位數(shù)碼管顯示 實(shí)驗(yàn)?zāi)康模?掌握數(shù)碼管掃描方式輸出。實(shí)現(xiàn)四位數(shù)碼管顯示和流水燈顯示。 實(shí)現(xiàn) 數(shù)碼管顯示 “Axxx” xxx從 000累計(jì)加 1至 99,發(fā)光二極管由三個(gè)小燈組成 跑馬 燈。 試驗(yàn)程序: include /* for EnableInterrupts macro */ include /* include peripheral declarations */ define on 0 define off 1 define led PTED define seg0 P