PIN state change problem
Hello, I am trying to create 100us seconds pulse which periodically triggers a triac. Timer 1 is used for periodic delay and a while loop is under the timer1 isr for 100us pulse. Problem is it is not working,Interrupt occurs but pin state doesn't change. Here is the code:
#include 'STM8S003F3P.h'
void InitialiseSystemClock(void);unsigned int i=500;void main(void){
InitialiseSystemClock(); // Internal RC clock initialization ,frequency 16MHZ
PD_DDR |=(1<<1); //PROT D is set as output PD_CR1 |=(1<<1); PD_CR2 |=(1<<1); TIM1_PSCRH=0; //timer1 setup for periodic interrupt TIM1_PSCRL=16; TIM1_ARRH=200; TIM1_ARRL=255; TIM1_IER=(1<<0); TIM1_CR1 =(1<<0);_asm('rim'); // Enable global interrupt while(1){ }
}
@far @interrupt void TIMER1_INTERRUPT (void){ // timer1 isr
PD_ODR |=(1<<1); // PD1 highwhile(i !=0){i--; // some micro seconds delay
}
PD_ODR &=~(1<<1); // PD1 lowTIM1_SR1 =~(1<<0);
return;
}Plese guide me,what to do.
