为什么我只能从 TImer0 中断获得 6 个脉冲?

问题描述

我只从中断中获得 RA2 (LED) 中的 6 个脉冲。信号应该是脉冲串(每秒一个脉冲)。这是模拟中的代码和图片 pulses comming from RA2 (LED) 希望你能帮我解决这个问题 最好的祝福, 理查

#include <pic.h>
#include <htc.h>

void Initialization ();

__CONFIG(FOSC_LP & WDTE_ON & PWRTE_OFF & CP_OFF);
#define _XTAL_FREQ 32768              

#define Drive1 RA0
#define Drive0 RA1
#define Machine RB4
#define LED RA2
#define Stall_In  RB0

int S = 0;                      

void main() 
{
    Initialization ();
    while (1)
    {
        //do something after interrupts     
    }
}
void Initialization(void)
{
    TRISA = 0b00000000;                 
    TRISB = 0b00000001;             
    OPTION_REG = 0b00000101;    
    INTCON = 0b10100000;            
    TMR0 = 128;                         
    LED = 0;
    Stall_In = 0;
    Drive0 = 0;
    Drive1 = 0;
    Machine  = 0;
}

void interrupt tc_int(void)
{    
    if (T0IE && T0IF) 
    {        
        T0IE = 0;
        T0IF=0;
        TMR0 = 128;
        S = S+1;
        LED = 1;
        LED = 0;
        T0IE = 1;           
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...