I only get, from the interrupts, 6 pulses in RA2 (LED). the signal should be a pulsetrain (one pulse every seccond). Here is the code and a pic from the simulation
pulses comming from RA2 (LED)
hope you can help me with this
best regards,
Richar
#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;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…