PCA捕获和定时器中断
时间:10-02
整理:3721RD
点击:
请问stc12c5608AD的pca捕获和普通定时器0有冲突吗,为什么PCA捕获中断进入不了,一直进入定时器溢出中断,程序如下:
#include"regc56.h"
#include"stdio.h"
#include"pwm.h"
#include"uart.h"
#include"pca.h"
sbit led1 =P2^5;
sbit dirt =P2^2;
sbit breaker=P2^3;
sbit key1 =P2^6;
sbit key2 =P2^7;
unsigned int j1,j2,j,j_form=0,DIRC;
long int pulse,T_speed;
void delay_ms(unsigned int x)
{
int a,b;
for(a=115;a>0;a--)
for(b=x;b>0;b--);
}
void main()
{
Init_PWM();
Init_uart();
Init_Pca();
Out_PWM(200);
CR=1;
EA=1;
while(1)
{
if(key1==0)
{
delay_ms(10);
if(key1==0)
{
dirt=1;
breaker=0;
Out_PWM(220);
}
}
else if(key2==0)
{
delay_ms(10);
if(key2==0)
{
dirt=1;
breaker=1;
}
}
}
}
void PCA_isr() interrupt 7
{
unsigned char j1,j2;
// breaker=1;
CCF1=0;
CCF3=0;
j1=P3&0x20;
j2=P2&0x10;
j=j1|j2;
j=j>>4;
if(j==3)
j=2;
else if(j==2)
j=3;
if((j==j_form+1)||((j==0)&&(j_form==3)))
{
DIRC=1;
pulse++;
led1=!led1;
}
else if((j==j_form-1)||((j==3)&&(j_form==0)))
{
DIRC=0;
pulse--;
led1=!led1;
}
j_form=j;
if((pulse==80)||(pulse==-80))
{
pulse=0;
if(DIRC)
T_speed++;
else
T_speed--;
}
led1=!led1;
delay_ms(10);
}
请大神指教,小弟在此谢过。
#include"regc56.h"
#include"stdio.h"
#include"pwm.h"
#include"uart.h"
#include"pca.h"
sbit led1 =P2^5;
sbit dirt =P2^2;
sbit breaker=P2^3;
sbit key1 =P2^6;
sbit key2 =P2^7;
unsigned int j1,j2,j,j_form=0,DIRC;
long int pulse,T_speed;
void delay_ms(unsigned int x)
{
int a,b;
for(a=115;a>0;a--)
for(b=x;b>0;b--);
}
void main()
{
Init_PWM();
Init_uart();
Init_Pca();
Out_PWM(200);
CR=1;
EA=1;
while(1)
{
if(key1==0)
{
delay_ms(10);
if(key1==0)
{
dirt=1;
breaker=0;
Out_PWM(220);
}
}
else if(key2==0)
{
delay_ms(10);
if(key2==0)
{
dirt=1;
breaker=1;
}
}
}
}
void PCA_isr() interrupt 7
{
unsigned char j1,j2;
// breaker=1;
CCF1=0;
CCF3=0;
j1=P3&0x20;
j2=P2&0x10;
j=j1|j2;
j=j>>4;
if(j==3)
j=2;
else if(j==2)
j=3;
if((j==j_form+1)||((j==0)&&(j_form==3)))
{
DIRC=1;
pulse++;
led1=!led1;
}
else if((j==j_form-1)||((j==3)&&(j_form==0)))
{
DIRC=0;
pulse--;
led1=!led1;
}
j_form=j;
if((pulse==80)||(pulse==-80))
{
pulse=0;
if(DIRC)
T_speed++;
else
T_speed--;
}
led1=!led1;
delay_ms(10);
}
请大神指教,小弟在此谢过。
学习下
我也发现没法进入中断,崩溃啊!有没有高人用过啊!我照着STC手册写的程序,结果没法进入中断,郁闷!
我也是,怎么解决呢!求助!