完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
在网上找到了一个简易心率测试仪的东西,大神们帮忙看看程序有没有问题吧
/* Project: Measuring heart rate through fingertip Copyright @ Rajendra Bhatt January 18, 2011 PIC16F628A at 4.0 MHz external clock, MCLR enabled */ ***it IR_Tx at RA3_bit; ***it DD0_Set at RA2_bit; ***it DD1_Set at RA1_bit; ***it DD2_Set at RA0_bit; ***it start at RB7_bit; unsigned short j, DD0, DD1, DD2, DD3; unsigned short pulserate, pulsecount; unsigned int i; //-------------- Function to Return mask for common anode 7-seg. display unsigned short mask(unsigned short num) { switch (num) { case 0 : return 0xC0; case 1 : return 0xF9; case 2 : return 0xA4; case 3 : return 0xB0; case 4 : return 0x99; case 5 : return 0x92; case 6 : return 0x82; case 7 : return 0xF8; case 8 : return 0x80; case 9 : return 0x90; } //case end } void delay_debounce(){ Delay_ms(300); } void delay_refresh(){ Delay_ms(5); } void countpulse(){ IR_Tx = 1; delay_debounce(); delay_debounce(); TMR0=0; Delay_ms(15000); // Delay 1 Sec IR_Tx = 0; pulsecount = TMR0; pulserate = pulsecount*4; } void display(){ DD0 = pulserate%10; DD0 = mask(DD0); DD1 = (pulserate/10)%10; DD1 = mask(DD1); DD2 = pulserate/100; DD2 = mask(DD2); for (i = 0; i<=180*j; i++) { DD0_Set = 0; DD1_Set = 1; DD2_Set = 1; PORTB = DD0; delay_refresh(); DD0_Set = 1; DD1_Set = 0; DD2_Set = 1; PORTB = DD1; delay_refresh(); DD0_Set = 1; DD1_Set = 1; DD2_Set = 0; PORTB = DD2; delay_refresh(); } DD2_Set = 1; } void main() { CMCON = 0x07; // Disable Comparators TRISA = 0b00110000; // RA4/T0CKI input, RA5 is I/P only TRISB = 0b10000000; // RB7 input, rest output OPTION_REG = 0b00101000; // Prescaler (1:1), TOCS =1 for counter mode pulserate = 0; j = 1; display(); do { if(!start){ delay_debounce(); countpulse(); j= 3; display(); } } while(1); // Infinite loop } |
|
相关推荐
1个回答
|
|
|
哦,用软件延时做个端口计数。大概就这样子吧。
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
【瑞萨RA6E2】瑞萨E2S软件安装过程,等待过程玩下97_e2 studio_ZGZZ
140 浏览 0 评论
483 浏览 0 评论
【原创】【RA4M2-SENSOR开发板评测】低功耗+USB综合测试
815 浏览 0 评论
1346 浏览 2 评论
804 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16907 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 20:46 , Processed in 0.581913 second(s), Total 74, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1062