pasmosodico
Newbie level 4

Hello everbody i have a proyect with the at898s52, i need a 1 useg delay to generate a square wave
im using keil uvison 3
this is my code:
#include <REGX52.h>
#include <stdio.h>
#include <intrins.h>
void T0Delay(void);
short int a=0;
void uartInit(void);
void main(void){
T0Delay();
uartInit();
while (1)
{
}
}
void T0Delay(){
TMOD=0x01;
//TL0=0x00;
//TH0=0xFF;
TR0=1;
ET0=1; /* enable timer0 interrupt */
EA=1; /* enable interrupts */
//while (TF0==0);
//TR0=0;
//TF0=0;
}
void ISR_Timer0(void) interrupt 1
{
TF0 = 0;
TL0=0xA5;
TH0=0xFF;
a++;
if(a<2){P1_5 =0;}
else{P1_5 =1;}
if(a==99){a=0;}
}
void uartInit(void) // con timer 2
{
SCON = 0x52; //01010010b
T2CON=0X34;
RCAP2H = 0xFF; //Corresponden a direcciones altas y bajas
RCAP2L= 0XD9; //para 19200(19230) baud rate 65496(en decimal)
TR2 = 1;
}
With this code i generate a 50 useg delay, work fine but now i need another delay aprox 1 usec to generate other square signal.
Can i, with keil generate very very small delay (1useg).How??
Any ideas please
Regards
(Sorry by my english)
---------- Post added at 20:06 ---------- Previous post was at 20:06 ----------
i am using a 24 mhz crystal
im using keil uvison 3
this is my code:
#include <REGX52.h>
#include <stdio.h>
#include <intrins.h>
void T0Delay(void);
short int a=0;
void uartInit(void);
void main(void){
T0Delay();
uartInit();
while (1)
{
}
}
void T0Delay(){
TMOD=0x01;
//TL0=0x00;
//TH0=0xFF;
TR0=1;
ET0=1; /* enable timer0 interrupt */
EA=1; /* enable interrupts */
//while (TF0==0);
//TR0=0;
//TF0=0;
}
void ISR_Timer0(void) interrupt 1
{
TF0 = 0;
TL0=0xA5;
TH0=0xFF;
a++;
if(a<2){P1_5 =0;}
else{P1_5 =1;}
if(a==99){a=0;}
}
void uartInit(void) // con timer 2
{
SCON = 0x52; //01010010b
T2CON=0X34;
RCAP2H = 0xFF; //Corresponden a direcciones altas y bajas
RCAP2L= 0XD9; //para 19200(19230) baud rate 65496(en decimal)
TR2 = 1;
}
With this code i generate a 50 useg delay, work fine but now i need another delay aprox 1 usec to generate other square signal.
Can i, with keil generate very very small delay (1useg).How??
Any ideas please
Regards
(Sorry by my english)
---------- Post added at 20:06 ---------- Previous post was at 20:06 ----------
i am using a 24 mhz crystal