PCF8591 A/D转换实验-测量电位器的电平

2019-04-13 21:52发布

测量电位器Rb2的电平值,并显示在数码管上。 首先要检查一下I2Cdelay()的时间够不够,因为一个_nop_()的时间是一个机器周期。
main.c #include #include "stdint.h" #include "PCF8591.h" #include "digitalTube.h" #include "timer.h" volatile bit flag300ms = 0; void main() { uint8_t value; uint8_t arry[3]; configTmr0(2); while (1) { if (flag300ms) { flag300ms = 0; value = getADCvalue(3); uint8_tToArray(arry, value); dspBuf[5] = arry[0]; dspBuf[6] = arry[1]; dspBuf[7] = arry[2]; } } } void tmr0ISR() interrupt 1 { static uint8_t cnt = 0; //!!! TL0 = tmr0LowByte; TH0 = tmr0HighByte; digitalTubeScan(); if (cnt == 150) { cnt = 0; flag300ms = 1; } else { cnt++; } }