连续社保 不能中断吗表示没有中断的意思吗?知道的解释一下,在下万分感谢

求大神帮忙看下串口中断啊
总是进不去中断是个什么情况
单步运行总停在__bis_SR_register(LPM0_bits+GIE);万分感谢! - MSP430(TM)16 位超低功耗 MCU - 德州仪器在线技术支持社区
求大神帮忙看下串口中断啊
总是进不去中断是个什么情况
单步运行总停在__bis_SR_register(LPM0_bits+GIE);万分感谢!
发表于3月前
<input type="hidden" id="hGroupID" value="37"
#include &msp430.h& &br>void chuankou();&br>void shizhong();&br>&br>vol&br>vol&br>void main(void)&br>{&br> WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer&br> P4DIR |= BIT7;&br> //anjian();&br> chuankou();&br> shizhong();&br> chuan = 0x3&br> __bis_SR_register(LPM0_bits+GIE);&br> while(1);&br>}&/p>
&p>void chuankou()&/p>
&p>{&br> P3SEL |=BIT3+BIT4;&br> UCA0CTL1 |=UCSWRST;&br> UCA0CTL1 |=UCSSEL_2;&br> UCA0BR0 = 6;&br> UCA0BR1 = 0;&br> UCA0MCTL =UCBRS_0 + UCBRF_13 + UCOS16;&br> UCA0CTL1 &= ~UCSWRST;&br> UCA0IE |= UCTXIE;&br>}&/p>
&p>void shizhong()&br>{&br> P2DIR |=BIT2;&br> P2SEL |=BIT2;&br> UCSCTL4 |= SELA_2;&br>}&br>#pragma vector=USIC_A0_VECTOR&br>__interrupt void USCI_A0_ISR()&br>{&br> switch(__even_in_range(UCA0IV,4))&br> {&br> case 0:&br> case 2:&br> case 4:&br> while(!(UCA0IFG&UCTXIFG));&br> UCA0TXBUF = 0x3&br> P4OUT |= BIT7;&br>&br> default:&br> }&br> UCA0IV = 0;&br>&br>}&/p>&div style=&clear:&>&/div>" />
求大神帮忙看下串口中断啊
总是进不去中断是个什么情况
单步运行总停在__bis_SR_register(LPM0_bits+GIE);万分感谢!
此问题尚无答案
All Replies
#include &msp430.h& void chuankou();void shizhong();volvolvoid main(void){ WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P4DIR |= BIT7; //anjian(); chuankou(); shizhong(); chuan = 0x3 __bis_SR_register(LPM0_bits+GIE); while(1);}
void chuankou()
{ P3SEL |=BIT3+BIT4; UCA0CTL1 |=UCSWRST; UCA0CTL1 |=UCSSEL_2; UCA0BR0 = 6; UCA0BR1 = 0; UCA0MCTL =UCBRS_0 + UCBRF_13 + UCOS16; UCA0CTL1 &= ~UCSWRST; UCA0IE |= UCTXIE;}
void shizhong(){ P2DIR |=BIT2; P2SEL |=BIT2; UCSCTL4 |= SELA_2;}#pragma vector=USIC_A0_VECTOR__interrupt void USCI_A0_ISR(){ switch(__even_in_range(UCA0IV,4)) { case 0: case 2: case 4: while(!(UCA0IFG&UCTXIFG)); UCA0TXBUF = 0x3 P4OUT |= BIT7; default: } UCA0IV = 0;}
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
状元38820分
楼主你好。你用的哪一款msp430?
430是跟电脑通讯么?&
建议先运行一下code example 试试
昵称:灰小子
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
我用的是f5529的单片机
想把数据发送给外部dac &
但是在debug里面一直调不对 不进入串口中断
不用中断直接写数据到UCA0TXBUF也没效果T_T&
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
状元38820分
dac用的哪个ic呢?
昵称:灰小子
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
dac用的8831
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
状元38820分
是spi接口的ic。我手里没有这个ic。
你参考官网的例程吧
/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of Texas Instruments Incorporated nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS&
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
MSP430 CODE EXAMPLE DISCLAIMER
* MSP430 code examples are self-contained low-level programs that typically
* demonstrate a single peripheral function or device feature in a highly
* concise manner. For this the code may rely on the device&#39;s power-on default
* register values and settings such as the clock configuration and care must
* be taken when combining code from several examples to avoid potential side
* effects. Also see /grace for a GUI- and /msp430ware
* for an API functional library-approach to peripheral configuration.
* --/COPYRIGHT--*/
//******************************************************************************
MSP430F552x Demo - USCI_A0, SPI 3-Wire Master Incremented Data
Description: SPI master talks to SPI slave using 3-wire mode. Incrementing
data is sent by the master starting at 0x01. Received data is expected to
be same as the previous transmission.
USCI RX ISR is used to handle
communication with the CPU, normally in LPM0. If high, P1.0 indicates
valid data reception.
Because all execution after LPM0 is in ISRs,
initialization waits for DCO to stabilize against ACLK.
ACLK = ~32.768kHz, MCLK = SMCLK = DCO ~ 1048kHz.
BRCLK = SMCLK/2
Use with SPI Slave Data Echo code example.
If slave is in debug mode, P1.1
slave reset signal conflicts with slave&#39;s JTAG; to work around, use IAR&#39;s
&Release JTAG on Go& on slave device.
If breakpoints are set in
slave RX ISR, master must stopped also to avoid overrunning slave
MSP430F552x
-----------------
P1.0|-& LED
P3.3|-& Data Out (UCA0SIMO)
P3.4|&- Data In (UCA0SOMI)
Slave reset &-|P1.1
P2.7|-& Serial Clock Out (UCA0CLK)
Bhargavi Nisarga
Texas Instruments Inc.
April 2009
Built with CCSv4 and IAR Embedded Workbench Version: 4.21
//******************************************************************************
#include &msp430.h&
unsigned char MST_Data,SLV_D
int main(void)
WDTCTL = WDTPW+WDTHOLD;
// Stop watchdog timer
P1OUT |= 0x02;
// Set P1.0 for LED
// Set P1.1 for slave reset
P1DIR |= 0x03;
// Set P1.0-2 to output direction
P3SEL |= BIT3+BIT4;
// P3.3,4 option select
P2SEL |= BIT7;
// P2.7 option select
UCA0CTL1 |= UCSWRST;
// **Put state machine in reset**
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB;
// 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 0x02;
UCA0BR1 = 0;
UCA0MCTL = 0;
// No modulation
UCA0CTL1 &= ~UCSWRST;
// **Initialize USCI state machine**
UCA0IE |= UCRXIE;
// Enable USCI_A0 RX interrupt
P1OUT &= ~0x02;
// Now with SPI signals initialized,
P1OUT |= 0x02;
// reset slave
for(i=50;i&0;i--);
// Wait for slave to initialize
MST_Data = 0x01;
// Initialize data values
SLV_Data = 0x00;
while (!(UCA0IFG&UCTXIFG));
// USCI_A0 TX buffer ready?
UCA0TXBUF = MST_D
// Transmit first character
__bis_SR_register(LPM0_bits + GIE);
// CPU off, enable interrupts
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#error Compiler not supported!
switch(__even_in_range(UCA0IV,4))
// Vector 0 - no interrupt
// Vector 2 - RXIFG
while (!(UCA0IFG&UCTXIFG));
// USCI_A0 TX buffer ready?
if (UCA0RXBUF==SLV_Data)
// Test for correct character RX&#39;d
P1OUT |= 0x01;
// If correct, light LED
P1OUT &= ~0x01;
// If incorrect, clear LED
MST_Data++;
// Increment data
SLV_Data++;
UCA0TXBUF = MST_D
// Send next value
for(i = 20; i&0; i--);
// Add time between transmissions to
// make sure slave can process information
// Vector 4 - TXIFG
昵称:灰小子
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
好的 &感谢您
You have posted to a forum that requires a moderator to approve posts before they are publicly available.副主任医师
本站已经通过实名认证,所有内容由杨季云大夫本人发表
帮我解释一下羊水穿刺检查单备注上的问题,万分感谢!
状态:就诊前
希望提供的帮助:
帮我解释一下羊水穿刺检查单备注上的问题,万分感谢!
检查资料:
&副主任医师
仅有一个细胞核型易位,不能认为是染色体异常。可能是培养过程中形成的,为假性嵌合体的可能性大。备注中给出的是方法的适应症及局限性,任何一种检查均有其适应症及局限性。微缺失或重复可以通过芯片的方法检查,但是芯片检查结果正常,同样的,单基因病还是不能诊断。因而,产前诊断是针对性的解决问题,而不是解决所有问题。就你的情况,不用过于担忧,按要求产检即可。
状态:就诊前
谢谢杨老师!可能是我高龄的原因,我怕孩子出生就有缺陷是对孩子不负责任,所以很感谢你的解答!谢谢!
状态:就诊前
杨老师,我就不需要再做遗传病方面进一步的检查,只需要做好产前检查是吗?
&副主任医师
是的,按要求产检吧!无需过度焦虑!
副主任医师
杨季云大夫通知出停诊:因工作安排,于日(周二)下午,日(周二),日(周二)下午停诊,请周知。
大夫郑重提醒:因不能面诊患者,无法全面了解病情,以上建议仅供参考,具体诊疗请一定到医院在医生指导下进行!
疾病名称:羊水穿刺&&
希望得到的帮助:现在纠结于做羊穿还是无创,希望得到医生的帮助
病情描述:中期唐筛结果18三体高危,医生建议羊水穿刺
疾病名称:产检唐筛高风险&&
希望得到的帮助:贵医院近期能否做羊水穿刺,大约什么时间能做
病情描述:唐筛高风险,想咨询一下,可以做羊水穿刺么,什么时候可以做
疾病名称:21三体&&
希望得到的帮助:是否要继续等羊穿核型报告?或进行脐带穿?已经20周
病情描述:男,29岁。无创提示高风险,羊穿快速分析提示婴儿携带21三体核型,有必要进一步确诊吗?已经20周
疾病名称:和老公都会不同型的地贫,现怀宝宝需做羊穿&&
希望得到的帮助:给一些建议,谢谢
病情描述:现在怀宝宝了,发现我是中度贫血,而且以前做的优生优育是领结婚证的时候,免费做的,然后给我打的电话,没给报告,这种情况有什么建议呢
疾病名称:耳聋基因报告分析,二胎风险率,如何建议&&
希望得到的帮助:我们什么时候去医院就诊比较合适?
病情描述:主任您好,我们夫妻正常,一胎宝宝双耳极重度耳聋,现在5岁,1.5岁时做的耳蜗手术,现在语言康复可以,一直上普幼,没有其他症状,我家现在怀孕二胎2个月了,不知道该怎么办,去年在301抽的血做...
疾病名称:怀孕&&
希望得到的帮助:请医生给我一些治疗上的建议
病情描述:怀孕12周,nt检查颈部水囊瘤,头部皮下水肿
疾病名称:胎儿三个月左侧胸腔有囊性结构并挤压到心脏&&
希望得到的帮助:可能是什么病灶?囊腺瘤?心包积液?还是普通囊肿?
病情描述:12周胎儿左侧胸腔有一个10mm×7mm的囊性结构。18周复查变为7mm×3mm的类似心包积液的现象。24周三维说看不到病灶,同一天也做了心脏彩超,存在3mm×1.8mm的无回声区。26周再次复查心脏彩超没有发...
疾病名称:21三体综合征468 要做羊水穿刺检查?&&
希望得到的帮助:咨询一下这种情况需要做羊水穿刺吗
病情描述:21三体综合征1:468,其他两个都是低风险
疾病名称:29周单脐动脉&&
希望得到的帮助:有什么要注意的吗?宝宝会有问题吗?
病情描述:今天照B超显示单脐动脉,请问严重吗?做过无创DNA,低风险
疾病名称:唐氏筛查高风险&&
希望得到的帮助:介绍有经验的医生和预约。
病情描述:九周三天检查唐氏筛查一个星期拿结果:高风险。
疾病名称:唐氏筛查&&
希望得到的帮助:除了做羊水穿刺还有别的什么方法
病情描述:无创dna查出来没问题但是有个附加信息说4号染色体微重复
疾病名称:胎儿多囊肾&&
希望得到的帮助:我下一步应该做些什么?二胎还会得这个病吗?
病情描述:已经怀孕24周了,刚刚检测出来是胎儿多囊肾,羊水少,胎儿发育迟缓,家族没有人得过多囊肾的
疾病名称:孕11周+5做早筛T21风险值1:674&&
希望得到的帮助:请给我一些治疗建议,谢谢!
病情描述:孕11周+5做的T21风险值1:674 参考值<1/270 这个数值属于什么情况?应该怎么办?
疾病名称:自身患马氏综合症,怀孕两个月&&
希望得到的帮助:如何检查胎儿是否患马氏综合征,体征检查还是基因检测
病情描述:患者及其奶奶、父亲、哥哥、侄子都患有马氏综合症,现患者有一女没有马氏综合症,2015年8月做过一次人流手术,现患者又怀孕两个月,能不能查出孩子是否患有马氏综合征
疾病名称:胎儿左侧侧室增宽1.21cm&&
希望得到的帮助:会脑积水么?
病情描述:女,27岁。左侧侧脑室增宽12.1,做了无创的,大排畸正常,
疾病名称:26周超声右侧胸腔强回声包块提示肺囊腺瘤&&
希望得到的帮助:可去门诊就诊
病情描述:没有家族史,自然受孕。早期有做无创检查,结果提示低风险孕23周B超结果
疾病名称:怀孕四个多月&&染色体13,14罗氏易位&&
希望得到的帮助:这个结果是肝功能有问题吗?羊水穿刺危险吗?做完穿刺离家有点远能坐车正常回去吗
病情描述:本人有染色体罗氏易位,前面流产过六次,这次怀上四个多月没有出过血,现在准备做羊水穿刺,乙肝检查结果有三个是阳性的,不知道怎么回事,上个月做了肝功能都没有问题,怎么这次结果这样,是有...
疾病名称:产前筛查:21三体综合症,年龄高风险&&
希望得到的帮助:我的情况要宝宝,确认下。
病情描述:21三体综合症筛查结果:年龄高峰险,确认产前筛查,请上级医院确认。
疾病名称:胎儿十二指肠陕窄或闭&&
希望得到的帮助:需要手术吗
病情描述:胎儿十二指肠陕窄或闭合,能生下来吗,,,
疾病名称:胎儿四维检查脑室紧贴脉络从一侧有稍强回声&&
希望得到的帮助:这个情况对孩子的影响到底有多大,有过同类型病情的?预后如何?会不会后期自行吸收?...
病情描述:前期检查都正常,做过无创DNA,都是低风险。因为这个紧贴脉络从稍强回声,超声医生不确定。到底是囊肿?还是出血?还是占位肿瘤?到底是脑室内?还是脑室外?最关键的是我们很想要这个孩子,不知...
投诉类型:
投诉说明:(200个汉字以内)
杨季云大夫的信息
遗传性疾病的基因诊断及产前诊断与遗传咨询。单基因遗传病(如多囊肾、血友病、视网膜色素变性、地中海贫血...
杨季云,男,研究员,硕士研究生导师。1996年毕业于第三军医大学,医学学士学位。2002年毕业于第三军医大学...
杨季云大夫的电话咨询
90%当天通话,沟通充分!
遗传咨询科可通话专家
副主任医师
安徽省立医院
优生遗传咨询专病门诊
河南省人民医院
医学遗传研究所
潍坊市妇幼保健院
遗传代谢病筛选科
副主任医师
自贡市妇幼保健院
遗传生殖医学中心
副主任医师
河南省人民医院
医学遗传研究所
湖北妇幼保健院
优生遗传科
郑大一附院
遗传与产前诊断中心查看: 1822|回复: 13
仿真结果不正确,不知道是程序还是仿真图错了,谁能帮忙一下?万分感谢
6.jpg (153.66 KB, 下载次数: 48)
14:30 上传
程序如下:
#include &AT89X52.h&
#define uint unsigned int
#define uchar unsigned char& &//宏定义
#define&&DQ&&P3_6& &&&//定义DS18B20总线I/O
#define SET&&P3_1& & //定义调整键
#define DEC&&P3_2& & //定义减少键
#define ADD&&P3_3& & //定义增加键
#define BEEP P3_7& & //定义蜂鸣器
bit shanshuo_& & //闪烁间隔标志
bit beep_& &&&//蜂鸣器间隔标志
sbit DIAN = P2^7;& && &&&//小数点
uchar x=0;& && &//计数器
& &&&//温度值全局变量
& && &//温度值全局变量
uchar set_st=0;& &&&//状态标志
signed char shangxian=38;&&//上限报警温度,默认值为38
signed char xiaxian=5;& &//下限报警温度,默认值为5
uchar code&&LEDData[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff};
/*****延时子程序*****/
void Delay_DS18B20(int num)
&&while(num--) ;
/*****初始化DS18B20*****/
void Init_DS18B20(void)
&&unsigned char x=0;
&&DQ = 1;& && && &//DQ复位
&&Delay_DS18B20(8);& & //稍做延时
&&DQ = 0;& && && &//单片机将DQ拉低
&&Delay_DS18B20(80);& &//精确延时,大于480us
&&DQ = 1;& && && &//拉高总线
&&Delay_DS18B20(14);
&&x = DQ;& && && &&&//稍做延时后,如果x=0则初始化成功,x=1则初始化失败
&&Delay_DS18B20(20);
/*****读一个字节*****/
unsigned char ReadOneChar(void)
&&unsigned char i=0;
&&unsigned char dat = 0;
&&for (i=8;i&0;i--)
DQ = 0;& &&&// 给脉冲信号
& & dat&&=1;
& & DQ = 1;& &&&// 给脉冲信号
& & if(DQ)
& & dat|=0x80;
& & Delay_DS18B20(4);
&&return(dat);
/*****写一个字节*****/
void WriteOneChar(unsigned char dat)
&&unsigned char i=0;
&&for (i=8; i&0; i--)
& & DQ = dat&0x01;
& & Delay_DS18B20(5);
& & DQ = 1;
& & dat&&=1;
/*****读取温度*****/
unsigned int ReadTemperature(void)
&&unsigned char a=0;
&&unsigned char b=0;
&&unsigned int t=0;
&&float tt=0;
&&Init_DS18B20();
&&WriteOneChar(0xCC);&&//跳过读序号列号的操作
&&WriteOneChar(0x44);&&//启动温度转换
&&Init_DS18B20();
&&WriteOneChar(0xCC);&&//跳过读序号列号的操作
&&WriteOneChar(0xBE);&&//读取温度寄存器
&&a=ReadOneChar();& &&&//读低8位
&&b=ReadOneChar();& & //读高8位
&&tt=t*0.0625;
&&t= tt*10+0.5;& &&&//放大10倍输出并四舍五入
&&return(t);
/*****延时子程序*****/
void Delay(uint num)
while( --num );
/*****初始化定时器0*****/
void InitTimer(void)
&&TMOD=0x1;
&&TH0=0x3c;
&&TL0=0xb0;& &&&//50ms(晶振12M)
/*****定时器0中断服务程序*****/
void timer0(void) interrupt 1
/*****外部中断0服务程序*****/
void int0(void) interrupt 0
&&EX0=0;& && &//关外部中断0
if(DEC==0&&set_st==1)
&&shangxian--;
&&if(shangxian&xiaxian)shangxian=
else if(DEC==0&&set_st==2)
&&xiaxian--;
&&if(xiaxian&0)xiaxian=0;
/*****外部中断1服务程序*****/
void int1(void) interrupt 2
EX1=0;& && &//关外部中断1
if(ADD==0&&set_st==1)
&&shangxian++;
&&if(shangxian&99)shangxian=99;
else if(ADD==0&&set_st==2)
&&xiaxian++;
&&if(xiaxian&shangxian)xiaxian=
/*****读取温度*****/
void check_wendu(void)
uint a,b,c;
c=ReadTemperature()-5;&&//获取温度值并减去DS18B20的温漂误差
a=c/100;& &&&//计算得到十位数字
b=c/10-a*10;& & //计算得到个位数字
m=c/10;& && &//计算得到整数位
n=c-a*100-b*10;& & //计算得到小数位
if(m&0){m=0;n=0;}& &//设置温度显示上限
if(m&99){m=99;n=9;}& &//设置温度显示上限& &
/*****显示开机初始化等待画面*****/
Disp_init()& &
P2 = 0& && &//显示-
P1 = 0xf7;
Delay(200);
Delay(200);& &
Delay(200);
Delay(200);
P1 = 0& && && &//关闭显示
/*****显示温度子程序*****/
Disp_Temperature()& &&&//显示温度
P2 =0xc6;& && &//显示C
P1 = 0xf7;
Delay(300);
P2 =LEDData[n];& & //显示个位
Delay(300);
P2 =LEDData[m%10];& & //显示十位
DIAN = 0;& && && &//显示小数点
Delay(300);
P2 =LEDData[m/10];& & //显示百位
Delay(300);
P1 = 0& && && &//关闭显示
/*****显示报警温度子程序*****/
Disp_alarm(uchar baojing)
P2 =0xc6;& && &//显示C
P1 = 0xf7;
Delay(200);
P2 =LEDData[baojing%10]; //显示十位
Delay(200);
P2 =LEDData[baojing/10]; //显示百位
Delay(200);
if(set_st==1)P2 =0x89;
else if(set_st==2)P2 =0xc7; //上限H、下限L标示
Delay(200);
P1 = 0& && && &//关闭显示
/*****报警子程序*****/
void Alarm()
if(x&=10){beep_st=~beep_x=0;}
if((m&=shangxian&&beep_st==1)||(m&xiaxian&&beep_st==1))BEEP=0;
else BEEP=1;
/*****主函数*****/
void main(void)
InitTimer();& & //初始化定时器
EA=1;& && &//全局中断开关
ET0=1;& && &//开启定时器0
IT0=1;& && &&&
check_wendu();
check_wendu();
for(z=0;z&300;z++)
&&Disp_init();& && &&&
&&if(SET==0)
& &Delay(2000);
& &do{}while(SET==0);
& &set_st++;x=0;shanshuo_st=1;
& &if(set_st&2)set_st=0;
&&if(set_st==0)
& &EX0=0;& & //关闭外部中断0
& &EX1=0;& & //关闭外部中断1
& & check_wendu();
& && &Disp_Temperature();
& &Alarm();& &//报警检测
&&else if(set_st==1)
& &BEEP=1;& & //关闭蜂鸣器
& &EX0=1;& & //开启外部中断0
& &EX1=1;& & //开启外部中断1
& &if(x&=10){shanshuo_st=~shanshuo_x=0;}
& &if(shanshuo_st) {Disp_alarm(shangxian);}
&&else if(set_st==2)
& &BEEP=1;& & //关闭蜂鸣器
& &EX0=1;& & //开启外部中断0
& &EX1=1;& & //开启外部中断1
& &if(x&=10){shanshuo_st=~shanshuo_x=0;}
& &if(shanshuo_st) {Disp_alarm(xiaxian);}
/*****END*****/
显示仿真结果
360软件小助手截图51.png (61 KB, 下载次数: 49)
14:32 上传
三极管不加电阻的时候不显示温度
 这样的情况很多,往往仿真不成功,可是用硬件打个电路就可以成功的。有时侯硬件电路不成功,可是仿真却能通得过。
 程序有缺陷
/*****显示报警温度子程序*****/
Disp_alarm(uchar baojing)
P2 =0xc6;& && &//显示C
P1 = 0xf7;
Delay(200);P1 = 0
P2 =LEDData[baojing%10]; //显示十位
Delay(200);
P2 =LEDData[baojing/10]; //显示百位
Delay(200);
if(set_st==1)P2 =0x89;
else if(set_st==2)P2 =0xc7; //上限H、下限L标示
Delay(200);
P1 = 0& && && &//关闭显示
我查了一下说程序的延时有问题,应写成去抖延时,这有没有关系的?
/*****显示报警温度子程序*****/
Disp_alarm(uchar baojing)
你这程序是一样的啊,能不能说明一下如何去改啊
你这程序是一样的啊,能不能说明一下如何去改啊
sorry啊,改过了,但显示结果是一样的,是我图画错了吗?
建议你把仿真的工程文件和程序代码打包发上来,大家下载以后在本地调试一下。就能知道是哪里的错误了
前天安装了proteus,然后在论坛视频上学操作,拿你程序练手,发现proteus很操蛋,用三极管做数码管位选显示动态扫描不正常,换反相器74LS04做位选 正常。你程序显示要加消隐,不然也不正常。
file:///C:\Users\ADMINI~1\AppData\Local\Temp\msohtml1\01\clip_image002.gif
(17.78 KB, 下载次数: 57)
18:25 上传
刚学,画得很丑,见笑!
#include &AT89X52.h&
#define uint unsigned int
#define uchar unsigned char& &//宏定义
#define&&DQ&&P3_6& &&&//定义DS18B20总线I/O
#define SET&&P3_1& & //定义调整键
#define DEC&&P3_2& & //定义减少键
#define ADD&&P3_3& & //定义增加键
#define BEEP P3_7& & //定义蜂鸣器
bit shanshuo_& & //闪烁间隔标志
bit beep_& &&&//蜂鸣器间隔标志
sbit DIAN = P2^7;& && &&&//小数点
uchar x=0;& && &//计数器
& &&&//温度值全局变量
& && &//温度值全局变量
uchar set_st=0;& &&&//状态标志
signed char shangxian=38;&&//上限报警温度,默认值为38
signed char xiaxian=5;& &//下限报警温度,默认值为5
uchar code&&LEDData[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff};
/*****延时子程序*****/
void Delay_DS18B20(int num)
&&while(num--) ;
/*****初始化DS18B20*****/
void Init_DS18B20(void)
&&unsigned char x=0;
&&DQ = 1;& && && &//DQ复位
&&Delay_DS18B20(8);& & //稍做延时
&&DQ = 0;& && && &//单片机将DQ拉低
&&Delay_DS18B20(80);& &//精确延时,大于480us
&&DQ = 1;& && && &//拉高总线
&&Delay_DS18B20(14);
&&x = DQ;& && && &&&//稍做延时后,如果x=0则初始化成功,x=1则初始化失败
&&Delay_DS18B20(20);
/*****读一个字节*****/
unsigned char ReadOneChar(void)
&&unsigned char i=0;
&&unsigned char dat = 0;
&&for (i=8;i&0;i--)
& & DQ = 0;& &&&// 给脉冲信号
& & dat&&=1;
& & DQ = 1;& &&&// 给脉冲信号
& & if(DQ)
& & dat|=0x80;
& & Delay_DS18B20(4);
&&return(dat);
/*****写一个字节*****/
void WriteOneChar(unsigned char dat)
&&unsigned char i=0;
&&for (i=8; i&0; i--)
& & DQ = 0;
& & DQ = dat&0x01;
& & Delay_DS18B20(5);
& & DQ = 1;
& & dat&&=1;
/*****读取温度*****/
unsigned int ReadTemperature(void)
&&unsigned char a=0;
&&unsigned char b=0;
&&unsigned int t=0;
&&float tt=0;
&&Init_DS18B20();
&&WriteOneChar(0xCC);&&//跳过读序号列号的操作
&&WriteOneChar(0x44);&&//启动温度转换
&&Init_DS18B20();
&&WriteOneChar(0xCC);&&//跳过读序号列号的操作
&&WriteOneChar(0xBE);&&//读取温度寄存器
&&a=ReadOneChar();& &&&//读低8位
&&b=ReadOneChar();& & //读高8位
&&tt=t*0.0625;
&&t= tt*10+0.5;& &&&//放大10倍输出并四舍五入
&&return(t);
/*****延时子程序*****/
void Delay(uint num)
& &while( --num );
/*****初始化定时器0*****/
void InitTimer(void)
&&TMOD=0x1;
&&TH0=0x3c;
&&TL0=0xb0;& &&&//50ms(晶振12M)
/*****定时器0中断服务程序*****/
void timer0(void) interrupt 1
& & & & TH0=0x3c;
& & & & TL0=0xb0;
& & & & x++;
/*****外部中断0服务程序*****/
void int0(void) interrupt 0
& & EX0=0;& && &//关外部中断0
& & & & if(DEC==0&&set_st==1)
& & & && &shangxian--;
& & & && &if(shangxian&xiaxian)
& & & && & shangxian=
& & & & else if(DEC==0&&set_st==2)
& & & && &xiaxian--;
& & & && &if(xiaxian&0)xiaxian=0;
/*****外部中断1服务程序*****/
void int1(void) interrupt 2
& & & & EX1=0;& && &//关外部中断1
& & & & if(ADD==0&&set_st==1)
& & & && &shangxian++;
& & & && &if(shangxian&99)shangxian=99;
& & & & else if(ADD==0&&set_st==2)
& & & && &xiaxian++;
& & & && &if(xiaxian&shangxian)xiaxian=
& & & & }&&
/*****读取温度*****/
void check_wendu(void)
& & & & uint a,b,c;
& & & & c=ReadTemperature();&&//获取温度值并减去DS18B20的温漂误差
& & & & a=c/100;& &&&//计算得到十位数字
& & & & b=c/10-a*10;& & //计算得到个位数字
& & & & m=c/10;& && &//计算得到整数位
& & & & n=c-a*100-b*10;& & //计算得到小数位
& & & & if(m&0){m=0;n=0;}& &//设置温度显示上限
& & & & if(m&99){m=99;n=9;}& &//设置温度显示上限& &
/*****显示开机初始化等待画面*****/
Disp_init()& &
& & & & P2 = 0& && &//显示-
& & & & P1 = 0xf7;
& & & & Delay(200);
& & & & P1 = 0
& & & & Delay(200);& &
& & & & P1 = 0
& & & & Delay(200);
& & & & P1 = 0
& & & & Delay(200);
& & & & P1 = 0& && && &//关闭显示
/*****显示温度子程序*****/
Disp_Temperature()& &&&//显示温度
P1 = 0xf7;& && &//显示C
Delay(300);
P2 =LEDData[n];
P1 = 0& &//显示个位
Delay(300);& & & & //显示小数点
P2=0XFF;& && &&&
P2 =LEDData[m%10];& & //显示十位
Delay(300);
P2 =LEDData[m/10];
P1 = 0& & //显示百位
Delay(300);
/*****显示报警温度子程序*****/
Disp_alarm(uchar baojing)
& & & & P2 =0xc6;& && &//显示C
& & & & P1 = 0xf7;
& & & & Delay(300);
& & & & P2=0XFF;
& & & & P2 =LEDData[baojing%10]; //显示十位
& & & & P1 = 0
& & & & Delay(300);
& & & & P2=0XFF;
& & & & P2 =LEDData[baojing/10]; //显示百位
& & & & P1 = 0
& & & & Delay(300);
& & & & P2=0XFF;
& & & & if(set_st==1)
& & & & P2 =0x89;
& & & & else if(set_st==2)
& & & & P2 =0xc7; //上限H、下限L标示
& & & & P1 = 0
& & & & Delay(300);
& & & & P2 = 0& && && &//关闭显示
/*****报警子程序*****/
void Alarm()
& & & & if(x&=10){beep_st=~beep_x=0;}
& & & & if((m&=shangxian&&beep_st==1)||(m&xiaxian&&beep_st==1))BEEP=0;
& & & & else BEEP=1;
/*****主函数*****/
void main(void)
& & & & InitTimer();& & //初始化定时器
& & & & EA=1;& && &//全局中断开关
& & & & TR0=1;
& & & & ET0=1;& && &//开启定时器0
& & & & IT0=1;& && &&&
& & & & IT1=1;
& & & & check_wendu();
& & & & check_wendu();
& & & & for(z=0;z&300;z++)
& & & && &Disp_init();& && &&&
& & & && &}
& & & & while(1)
& & & && &{
& & & & & & & && &if(SET==0)
& & & & & & & && &{
& & & & & & & && & Delay(20);
& & & & & & & && & do{}while(SET==0);
& & & & & & & && & set_st++;
& & & & & & & && & x=0;
& & & & & & & && & shanshuo_st=1;
& & & & & & & && & if(set_st&2)set_st=0;
& & & & & & & && &}
& & & & & & & && &if(set_st==0)
& & & & & & & && &{
& & & & & & & && & EX0=0;& & //关闭外部中断0
& & & & & & & && & EX1=0;& & //关闭外部中断1
& & & & & & & && & check_wendu();
& & & & & & & && & Disp_Temperature();
& & & & & & & && & Alarm();& &//报警检测
& & & & & & & && &}
& & & & & & & && &else if(set_st==1)
& & & & & & & && &{
& & & & & & & && & BEEP=1;& & //关闭蜂鸣器
& & & & & & & && & EX0=1;& & //开启外部中断0
& & & & & & & && & EX1=1;& & //开启外部中断1
& & & & & & & && & if(x&=10){shanshuo_st=~shanshuo_x=0;}
& & & & & & & && & if(shanshuo_st) {Disp_alarm(shangxian);}
& & & & & & & && &}
& & & & & & & && &else if(set_st==2)
& & & & & & & && &{
& & & & & & & && & BEEP=1;& & //关闭蜂鸣器
& & & & & & & && & EX0=1;& & //开启外部中断0
& & & & & & & && & EX1=1;& & //开启外部中断1
& & & & & & & && & if(x&=10){shanshuo_st=~shanshuo_x=0;}
& & & & & & & && & if(shanshuo_st) {Disp_alarm(xiaxian);}
& & & & & & & && &}
& & & & & & & &&&
& & & && &&&}
/*****END*****/
回帖助人的奖励!
正在学习中。。。。。。
用三极管做位选其极电极要加下拉电阻。
猎豹截图19.png (53.24 KB, 下载次数: 41)
15:54 上传
Powered by

我要回帖

更多关于 连续不中断缴费年限 的文章

 

随机推荐