pradipdabhi
Newbie level 2
I have Made light dimmer with 89C52 using RC5 Infra red remote VOL+ and VOL- key.
RC5 IR interrupt is External Int. 0
timer0 interrupt for RC5 command processing.
Zero Crossing interrupt is External Int 1
Timer1 interrupt for trigger TRIAC
I am firing TRIAC with PIN 2_7.
My program works OK, till the timer1 interrupt for triggering TRIAC not occour.
My routine is as below
the SPEED variable is int and Filled through RC5 decoded command.
My PROBLEM is in TRIGGER routine which is Timer routine
This is not full program but i put some part of it here.
//=========================================================
#define IE0_VECTOR 0 /* 0x03 External interrupt 0 */
#define TF0_VECTOR 1 /* 0x0B Timer 0 */
#define IE1_VECTOR 2 /* 0x13 External interrupt 1 */
#define TF1_VECTOR 3 /* 0x1B Timer 1 */
#define SIO_VECTOR 4 /* 0x23 Serial port */
void ZeroCross(void) interrupt IE1_VECTOR using 1
{
if (SPEED==8)
{
TR1=0;
P2_7=0;
}
else if (SPEED==7)
{
TL1=0xFF;
TH1=0xFA;
ET1=1;
TR1=1;
}
else if (SPEED==6)
{
TL1=0xFF;
TH1=0xF9;
ET1=1;
TR1=1;
}
else if (SPEED==5)
{
TL1=0xFF;
TH1=0xF7;
ET1=1;
TR1=1;
}
else if (SPEED==4)
{
TL1=0xFF;
TH1=0xF6;
ET1=1;
TR1=1;
}
else if (SPEED==3)
{
TL1=0xFF;
TH1=0xF4;
ET1=1;
TR1=1;
}
else if (SPEED==2)
{
TL1=0xFF;
TH1=0xF0;
ET1=1;
TR1=1;
}
else if ((SPEED & 0x01)==0x01)
{
TL1=0x11;
TH1=0xF0;
ET1=1;
TR1=1;
}
else if (SPEED==0)
{
P2_7=1;
TR1=0;
}
}
void TRIGGER(void) interrupt TF1_VECTOR //Timer1 Ruotine For Trigger TRIAC
{
ET1=0;
TR1=0;
P2_7=1;
int t;
for(t=0;t<200;t++); // Problem is HERE while i m writing this sentence FOR LOOP. my program goes freeze. My RC5 Extrn. interrupt 0 for receiving IR is not workig after writing this line. and this sentence is necessary to FIRE TRIAC.
P2_7=0;
}
void main()
{
TMOD = 0x11;
EX0=1; // Extranal 0 interrupt for RC5 IR Receiving
IT0=1;
IE0=0;
IT1=1; // Extranal 1 interrupt for zero crossing
EX1=1;
EA=1; // Enable All Int.
while (1)
{
if ((command & 0x11) >= 0x11)
{
if (SPEED>0)
{
SPEED=SPEED-1;
}
delay_ms(500);
}
else if ((command & 0x10) >= 0x10)
{
if (SPEED>0)
{
SPEED=SPEED+1;
}
delay_ms(500);
}
}
}
//=========================================================
Please Help ME
RC5 IR interrupt is External Int. 0
timer0 interrupt for RC5 command processing.
Zero Crossing interrupt is External Int 1
Timer1 interrupt for trigger TRIAC
I am firing TRIAC with PIN 2_7.
My program works OK, till the timer1 interrupt for triggering TRIAC not occour.
My routine is as below
the SPEED variable is int and Filled through RC5 decoded command.
My PROBLEM is in TRIGGER routine which is Timer routine
This is not full program but i put some part of it here.
//=========================================================
#define IE0_VECTOR 0 /* 0x03 External interrupt 0 */
#define TF0_VECTOR 1 /* 0x0B Timer 0 */
#define IE1_VECTOR 2 /* 0x13 External interrupt 1 */
#define TF1_VECTOR 3 /* 0x1B Timer 1 */
#define SIO_VECTOR 4 /* 0x23 Serial port */
void ZeroCross(void) interrupt IE1_VECTOR using 1
{
if (SPEED==8)
{
TR1=0;
P2_7=0;
}
else if (SPEED==7)
{
TL1=0xFF;
TH1=0xFA;
ET1=1;
TR1=1;
}
else if (SPEED==6)
{
TL1=0xFF;
TH1=0xF9;
ET1=1;
TR1=1;
}
else if (SPEED==5)
{
TL1=0xFF;
TH1=0xF7;
ET1=1;
TR1=1;
}
else if (SPEED==4)
{
TL1=0xFF;
TH1=0xF6;
ET1=1;
TR1=1;
}
else if (SPEED==3)
{
TL1=0xFF;
TH1=0xF4;
ET1=1;
TR1=1;
}
else if (SPEED==2)
{
TL1=0xFF;
TH1=0xF0;
ET1=1;
TR1=1;
}
else if ((SPEED & 0x01)==0x01)
{
TL1=0x11;
TH1=0xF0;
ET1=1;
TR1=1;
}
else if (SPEED==0)
{
P2_7=1;
TR1=0;
}
}
void TRIGGER(void) interrupt TF1_VECTOR //Timer1 Ruotine For Trigger TRIAC
{
ET1=0;
TR1=0;
P2_7=1;
int t;
for(t=0;t<200;t++); // Problem is HERE while i m writing this sentence FOR LOOP. my program goes freeze. My RC5 Extrn. interrupt 0 for receiving IR is not workig after writing this line. and this sentence is necessary to FIRE TRIAC.
P2_7=0;
}
void main()
{
TMOD = 0x11;
EX0=1; // Extranal 0 interrupt for RC5 IR Receiving
IT0=1;
IE0=0;
IT1=1; // Extranal 1 interrupt for zero crossing
EX1=1;
EA=1; // Enable All Int.
while (1)
{
if ((command & 0x11) >= 0x11)
{
if (SPEED>0)
{
SPEED=SPEED-1;
}
delay_ms(500);
}
else if ((command & 0x10) >= 0x10)
{
if (SPEED>0)
{
SPEED=SPEED+1;
}
delay_ms(500);
}
}
}
//=========================================================
Please Help ME
Last edited: